Class: Rack::SocketDuplex
- Inherits:
-
Object
- Object
- Rack::SocketDuplex
- Defined in:
- lib/socket_duplex.rb
Constant Summary collapse
- MAX_QUEUE_SIZE =
50- NUM_OF_THREADS =
5
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, socket_path, secful_key, verify_mode = OpenSSL::SSL::VERIFY_PEER) ⇒ SocketDuplex
constructor
A new instance of SocketDuplex.
Constructor Details
#initialize(app, socket_path, secful_key, verify_mode = OpenSSL::SSL::VERIFY_PEER) ⇒ SocketDuplex
Returns a new instance of SocketDuplex.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/socket_duplex.rb', line 12 def initialize(app, socket_path, secful_key, verify_mode=OpenSSL::SSL::VERIFY_PEER) @app, @socket_path, @verify_mode = app, socket_path, verify_mode begin @secful_key = secful_key @agent_identifier = SecureRandom.hex @machine_ip = Socket.ip_address_list.detect(&:ipv4_private?).try(:ip_address) #@queue = SizedQueue.new(MAX_QUEUE_SIZE) @threads_to_sockets = {} #Thread.new { activate_workers() } Rails.logger.info "Process id: " + Process.pid.to_s Rails.logger.info "Init" rescue nil end end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/socket_duplex.rb', line 27 def call(env) begin if !defined? @queue @queue = SizedQueue.new(MAX_QUEUE_SIZE) activate_workers() Rails.logger.info "Process id: " + Process.pid.to_s Rails.logger.info "Init queue" end dup._call(env) rescue nil @app.call(env) end end |