Class: Estore::Commands::ReadBatch

Inherits:
Object
  • Object
show all
Includes:
Command, Command::ReadStreamForward
Defined in:
lib/estore/commands/read_batch.rb

Instance Attribute Summary

Attributes included from Command

#uuid

Instance Method Summary collapse

Methods included from Command::ReadStreamForward

#read

Methods included from Command

#decode, #promise, #register!, #reject!, #remove!, #write

Constructor Details

#initialize(connection, stream, from, limit) ⇒ ReadBatch

Returns a new instance of ReadBatch.



7
8
9
10
# File 'lib/estore/commands/read_batch.rb', line 7

def initialize(connection, stream, from, limit)
  super(connection)
  @stream, @from, @limit = stream, from, limit
end

Instance Method Details

#callObject



12
13
14
15
16
# File 'lib/estore/commands/read_batch.rb', line 12

def call
  register!
  read(@stream, @from, @limit)
  promise
end

#handle(message) ⇒ Object



18
19
20
21
22
# File 'lib/estore/commands/read_batch.rb', line 18

def handle(message, *)
  remove!
  response = decode(ReadStreamEventsCompleted, message)
  promise.fulfill(Array(response.events))
end