Class: Deepstream::AckTimeoutRegistry
- Inherits:
-
Object
- Object
- Deepstream::AckTimeoutRegistry
- Defined in:
- lib/deepstream/ack_timeout_registry.rb
Instance Method Summary collapse
- #add(name, message) ⇒ Object
- #cancel(name) ⇒ Object
-
#initialize(client) ⇒ AckTimeoutRegistry
constructor
A new instance of AckTimeoutRegistry.
Constructor Details
#initialize(client) ⇒ AckTimeoutRegistry
Returns a new instance of AckTimeoutRegistry.
3 4 5 6 |
# File 'lib/deepstream/ack_timeout_registry.rb', line 3 def initialize(client) @client = client @timeouts = {} end |
Instance Method Details
#add(name, message) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/deepstream/ack_timeout_registry.rb', line 8 def add(name, ) return unless (timeout = @client.[:ack_timeout]) @timeouts[name] = Thread.new do sleep timeout @client.on_error() end end |
#cancel(name) ⇒ Object
16 17 18 19 |
# File 'lib/deepstream/ack_timeout_registry.rb', line 16 def cancel(name) @timeouts[name].exit rescue nil @timeouts.delete(name) end |