Sha256: cf463f4a85770368c7899d9e5cae6aac5f37450ee7794ebb4830fa78da44afb9

Contents?: true

Size: 743 Bytes

Versions: 17

Compression:

Stored size: 743 Bytes

Contents

class Freddy
  class RequestManager
    def initialize(logger)
      @requests = ConcurrentHash.new
      @logger = logger
    end

    def no_route(correlation_id)
      if request = @requests[correlation_id]
        delete(correlation_id)
        request[:callback].call({error: 'Specified queue does not exist'}, nil)
      end
    end

    def store(correlation_id, opts)
      @requests[correlation_id] = opts
    end

    def delete(correlation_id)
      @requests.delete(correlation_id)
    end

    class ConcurrentHash < Hash
      # CRuby hash does not need any locks. Only adding when using JRuby.
      if RUBY_PLATFORM == 'java'
        require 'jruby/synchronized'
        include JRuby::Synchronized
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
freddy-1.4.1 lib/freddy/request_manager.rb
freddy-1.4.0 lib/freddy/request_manager.rb
freddy-1.3.3 lib/freddy/request_manager.rb
freddy-jruby-1.3.2 lib/freddy/request_manager.rb
freddy-1.3.2 lib/freddy/request_manager.rb
freddy-1.3.1 lib/freddy/request_manager.rb
freddy-1.3.0 lib/freddy/request_manager.rb
freddy-1.2.0 lib/freddy/request_manager.rb
freddy-1.1.0 lib/freddy/request_manager.rb
freddy-1.0.1 lib/freddy/request_manager.rb
freddy-jruby-1.0.0 lib/freddy/request_manager.rb
freddy-1.0.0 lib/freddy/request_manager.rb
freddy-jruby-0.7.2 lib/freddy/request_manager.rb
freddy-0.7.2 lib/freddy/request_manager.rb
freddy-0.7.1 lib/freddy/request_manager.rb
freddy-0.7.0 lib/freddy/request_manager.rb
freddy-0.6.3 lib/freddy/request_manager.rb