Sha256: 02e5c03521548a0655ef3125ac6e41e3d5f9cac6ab7d7de4ea0bf9891f3a753a

Contents?: true

Size: 433 Bytes

Versions: 11

Compression:

Stored size: 433 Bytes

Contents

module Deepstream
  class AckTimeoutRegistry
    def initialize(client)
      @client = client
      @timeouts = {}
    end

    def add(name, message)
      return unless (timeout = @client.options[:ack_timeout])
      @timeouts[name] = Thread.new do
        sleep timeout
        @client.on_error(message)
      end
    end

    def cancel(name)
      @timeouts[name].exit rescue nil
      @timeouts.delete(name)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
deepstream-1.0.10 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.9 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.8 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.7 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.6 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.5 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.4 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.3 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.2 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.1 lib/deepstream/ack_timeout_registry.rb
deepstream-1.0.0 lib/deepstream/ack_timeout_registry.rb