Class: QueueingProxy::DSL
- Inherits:
-
Object
- Object
- QueueingProxy::DSL
- Defined in:
- lib/queueing_proxy/dsl.rb
Defined Under Namespace
Classes: Backend
Instance Method Summary collapse
- #from(host, port = 80, &block) ⇒ Object
-
#initialize(&block) ⇒ DSL
constructor
A new instance of DSL.
- #logger(logger) ⇒ Object
- #run ⇒ Object
- #to(host, port = 80, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ DSL
Returns a new instance of DSL.
34 35 36 37 |
# File 'lib/queueing_proxy/dsl.rb', line 34 def initialize(&block) @logger = Logger.new($stdout) instance_eval(&block) if block end |
Instance Method Details
#from(host, port = 80, &block) ⇒ Object
44 45 46 47 |
# File 'lib/queueing_proxy/dsl.rb', line 44 def from(host, port=80, &block) frontends << [host, port] self end |
#logger(logger) ⇒ Object
49 50 51 52 |
# File 'lib/queueing_proxy/dsl.rb', line 49 def logger(logger) @logger = logger self end |
#run ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/queueing_proxy/dsl.rb', line 54 def run unless EM.reactor_running? EM.run{ run } else # Setup multiple backends backends.each {|b| b.logger @logger b.workers.each(&:run) } frontends.each do |host, port| Frontend.new(@logger, host, port, backends).run end end end |