Class: Fabric::EventHub
Constant Summary
collapse
- MAX_BLOCK_NUMBER =
4_611_686_018_427_387_903.freeze
Constants inherited
from ClientStub
ClientStub::VALID_OPTIONS_KEYS
Instance Attribute Summary
Attributes inherited from ClientStub
#creds, #host, #logger, #options
Instance Method Summary
collapse
Methods inherited from ClientStub
#initialize
Instance Method Details
#client ⇒ Object
5
6
7
|
# File 'lib/fabric/event_hub.rb', line 5
def client
@client ||= ::Protos::Deliver::Stub.new host, creds, options
end
|
#connection ⇒ Object
13
14
15
|
# File 'lib/fabric/event_hub.rb', line 13
def connection
@connection ||= client.deliver(queue.each).each
end
|
#observe(channel_id, identity, start_block = :newest, stop_block = MAX_BLOCK_NUMBER) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/fabric/event_hub.rb', line 17
def observe(channel_id, identity, start_block = :newest, stop_block = MAX_BLOCK_NUMBER)
tx_info = Fabric::TransactionInfo.new identity
= channel_id, tx_info
seek_info = build_seek_info start_block, stop_block
envelope = build_envelope tx_info, , seek_info
loop do
queue.push envelope
event = connection.next
block = Fabric::BlockDecoder.decode_block(event.block)
yield block if block_given?
end
end
|