Class: Kage::ProxyServer
- Inherits:
-
Proxy
- Object
- Proxy
- Kage::ProxyServer
- Defined in:
- lib/kage/proxy_server.rb
Instance Attribute Summary collapse
-
#backend_timeout ⇒ Object
Returns the value of attribute backend_timeout.
-
#backends ⇒ Object
Returns the value of attribute backends.
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#host ⇒ Object
Returns the value of attribute host.
-
#master ⇒ Object
Returns the value of attribute master.
-
#port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
- #add_backend(name, host, port = 80) ⇒ Object
- #add_master_backend(name, host, port = 80) ⇒ Object
-
#initialize(options = {}) ⇒ ProxyServer
constructor
A new instance of ProxyServer.
- #on_backends_finished(&blk) ⇒ Object
- #on_munge_headers(&blk) ⇒ Object
- #on_select_backends(&blk) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ProxyServer
Returns a new instance of ProxyServer.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kage/proxy_server.rb', line 8 def initialize( = {}) @host = '0.0.0.0' @port = 80 @debug = false @client_timeout = 15 @backend_timeout = 30 @backends = {} @master = nil @callbacks = {} .each do |k, v| send("#{k}=", v) end end |
Instance Attribute Details
#backend_timeout ⇒ Object
Returns the value of attribute backend_timeout.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def backend_timeout @backend_timeout end |
#backends ⇒ Object
Returns the value of attribute backends.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def backends @backends end |
#callbacks ⇒ Object
Returns the value of attribute callbacks.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def callbacks @callbacks end |
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def client_timeout @client_timeout end |
#debug ⇒ Object
Returns the value of attribute debug.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def debug @debug end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def host @host end |
#master ⇒ Object
Returns the value of attribute master.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def master @master end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/kage/proxy_server.rb', line 6 def port @port end |
Class Method Details
.start(options = {}, &blk) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kage/proxy_server.rb', line 36 def self.start( = {}, &blk) server = new() server.instance_eval &blk if server.master.nil? raise "Configuration error: no master backend defined" end super(:host => server.host, :port => server.port, :debug => server.debug) do |conn| conn.extend Connection conn.handle(server) end end |
Instance Method Details
#add_backend(name, host, port = 80) ⇒ Object
32 33 34 |
# File 'lib/kage/proxy_server.rb', line 32 def add_backend(name, host, port = 80) @backends[name] = {:host => host, :port => port} end |
#add_master_backend(name, host, port = 80) ⇒ Object
27 28 29 30 |
# File 'lib/kage/proxy_server.rb', line 27 def add_master_backend(name, host, port = 80) @master = name add_backend(name, host, port) end |
#on_backends_finished(&blk) ⇒ Object
25 |
# File 'lib/kage/proxy_server.rb', line 25 def on_backends_finished(&blk); @callbacks[:on_backends_finished] = blk; end |
#on_munge_headers(&blk) ⇒ Object
24 |
# File 'lib/kage/proxy_server.rb', line 24 def on_munge_headers(&blk); @callbacks[:on_munge_headers] = blk; end |
#on_select_backends(&blk) ⇒ Object
23 |
# File 'lib/kage/proxy_server.rb', line 23 def on_select_backends(&blk); @callbacks[:on_select_backends] = blk; end |