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 |
# File 'lib/deepstream/ack_timeout_registry.rb', line 8 def add(name, ) return unless (timeout = @client.[:ack_timeout]) @timeouts[name] = Celluloid.after(timeout) { @client.on_error() } end |
#cancel(name) ⇒ Object
13 14 15 |
# File 'lib/deepstream/ack_timeout_registry.rb', line 13 def cancel(name) @timeouts.delete(name)&.cancel end |