Module: Scales::Server::Proxy

Defined in:
lib/scales-server/proxy.rb,
lib/scales-server/proxy/backend.rb,
lib/scales-server/proxy/callbacks.rb

Defined Under Namespace

Modules: Callbacks Classes: Backend

Class Method Summary collapse

Class Method Details

.run!(host = '0.0.0.0', port = 9999) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scales-server/proxy.rb', line 9

def run!(host = '0.0.0.0', port = 9999)
  
  puts "Proxy Port:     #{port}".green
  puts "Server Ports:   #{Backend.ports.join(', ')}".green
  
  ::Proxy.start(:host => host, :port => port, :debug => false) do |connection|

    Backend.select do |backend|
      connection.server backend, :host => backend.host, :port => backend.port

      connection.on_connect  &Callbacks.on_connect
      connection.on_data     &Callbacks.on_data
      connection.on_response &Callbacks.on_response
      connection.on_finish   &Callbacks.on_finish
    end

  end
end