Class: Rack::SocketDuplex

Inherits:
Object
  • Object
show all
Defined in:
lib/socket_duplex.rb

Constant Summary collapse

MAX_QUEUE_SIZE =
50
NUM_OF_THREADS =
5

Instance Method Summary collapse

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
# 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() }
  rescue nil  
  end
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/socket_duplex.rb', line 25

def call(env)
  begin
    if !defined? @queue
      @queue = SizedQueue.new(MAX_QUEUE_SIZE)
      activate_workers()
    end
    dup._call(env)
  rescue nil
    @app.call(env)
  end
end