Class: Bones::RPC::Node::Registry
- Inherits:
-
Object
- Object
- Bones::RPC::Node::Registry
- Defined in:
- lib/bones/rpc/node/registry.rb
Overview
Instance Method Summary collapse
- #flush(exception = Errors::ConnectionFailure.new("Socket closed")) ⇒ Object
- #get(channel, id) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #set(channel, id, future) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
7 8 9 |
# File 'lib/bones/rpc/node/registry.rb', line 7 def initialize @registry = {} end |
Instance Method Details
#flush(exception = Errors::ConnectionFailure.new("Socket closed")) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/bones/rpc/node/registry.rb', line 11 def flush(exception = Errors::ConnectionFailure.new("Socket closed")) return true if @registry.empty? @registry.each do |channel, futures| futures.each do |id, future| future.signal(FutureValue.new(exception)) rescue nil end end @registry.clear end |
#get(channel, id) ⇒ Object
21 22 23 |
# File 'lib/bones/rpc/node/registry.rb', line 21 def get(channel, id) (@registry[channel] ||= {}).delete(id) end |
#set(channel, id, future) ⇒ Object
25 26 27 |
# File 'lib/bones/rpc/node/registry.rb', line 25 def set(channel, id, future) (@registry[channel] ||= {})[id] = future end |