Class: EventStoreClient::GRPC::Commands::Streams::ReadAll

Inherits:
Command
  • Object
show all
Includes:
Configuration
Defined in:
lib/event_store_client/adapters/grpc/commands/streams/read_all.rb

Instance Method Summary collapse

Methods included from Configuration

#config

Methods inherited from Command

inherited, #metadata

Instance Method Details

#call(stream_name, options: {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/event_store_client/adapters/grpc/commands/streams/read_all.rb', line 21

def call(stream_name, options: {})
  start ||= options[:start] || 0
  count ||= options[:count] || 20
  events = []

  loop do
    res = Read.new.call(
      stream_name, options: options.merge(start: start, count: count)
    )
    break if res.failure?
    break if (entries = res.value!).empty?

    events += entries
    start += count
  end

  Success(events)
end