Class: Estore::Commands::ReadBatch

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

Instance Attribute Summary

Attributes included from Command

#uuid

Instance Method Summary collapse

Methods included from ReadStreamForward

#error, #read

Methods included from Command

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

Constructor Details

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

Returns a new instance of ReadBatch.



9
10
11
12
# File 'lib/estore/commands/reads/batch.rb', line 9

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

Instance Method Details

#callObject



14
15
16
17
18
# File 'lib/estore/commands/reads/batch.rb', line 14

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

#completed(response) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/estore/commands/reads/batch.rb', line 20

def completed(response)
  remove!
  error = error(response)

  if error
    promise.reject error
  else
    promise.fulfill(Array(response.events))
  end
end