class EventSource::EventStore::HTTP::Get

Public Class Methods

build(batch_size: nil, long_poll_duration: nil, session: nil) click to toggle source
# File lib/event_source/event_store/http/get.rb, line 18
def self.build(batch_size: nil, long_poll_duration: nil, session: nil)
  instance = new batch_size, long_poll_duration

  session = Session.configure instance, session: session
  ::EventStore::HTTP::ReadStream.configure instance, session: session

  instance.configure
  instance
end
call(stream_name, position: nil, **build_arguments) click to toggle source
# File lib/event_source/event_store/http/get.rb, line 28
def self.call(stream_name, position: nil, **build_arguments)
  instance = build **build_arguments
  instance.(stream_name, position: position)
end

Public Instance Methods

batch_size() click to toggle source
# File lib/event_source/event_store/http/get.rb, line 11
def batch_size
  @batch_size ||= Defaults.batch_size
end
call(stream_name, position: nil) click to toggle source
# File lib/event_source/event_store/http/get.rb, line 42
def call(stream_name, position: nil)
  logger.trace { "Reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size})" }

  begin
    events = read_stream.(
      stream_name,
      position: position,
      batch_size: batch_size
    )
  rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
    events = []
  end

  logger.debug { "Done reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size}, Events: #{events.count})" }

  events
end
configure() click to toggle source
# File lib/event_source/event_store/http/get.rb, line 33
def configure
  read_stream.embed_body
  read_stream.output_schema = Result

  unless long_poll_duration.nil?
    read_stream.enable_long_poll long_poll_duration
  end
end