Class: QueueingProxy::Frontend
- Inherits:
-
Object
- Object
- QueueingProxy::Frontend
- Defined in:
- lib/queueing_proxy/frontend.rb
Defined Under Namespace
Classes: FakeBackend, Queuer
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #beanstalks ⇒ Object
-
#initialize(logger, host, port, backends) ⇒ Frontend
constructor
A new instance of Frontend.
- #run ⇒ Object
Constructor Details
#initialize(logger, host, port, backends) ⇒ Frontend
Returns a new instance of Frontend.
5 6 7 8 |
# File 'lib/queueing_proxy/frontend.rb', line 5 def initialize(logger, host, port, backends) @logger, @host, @port, @backends = logger, host, port, backends logger.info "Frontend reporting for duty at #{host}:#{port}. Connected to backend(s) through #{backends.map{|b| "#{b.tube}@#{b.beanstalk_host}"}.join(', ')}" end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/queueing_proxy/frontend.rb', line 3 def logger @logger end |
Instance Method Details
#beanstalks ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/queueing_proxy/frontend.rb', line 10 def beanstalks @beanstalks ||= @backends.map {|b| connection = EMJack::Connection.new(:host => b.beanstalk_host, :tube => b.tube) connection.errback { logger.error "Couldn't connect to beanstalk" } connection } end |
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/queueing_proxy/frontend.rb', line 18 def run app = proc do |env| logger.info "Frontend frontend #{env['HTTP_VERSION']} #{env['PATH_INFO']} #{env['REQUEST_METHOD']}" [200, {}, []] end backend = FakeBackend.new EM.start_server(@host, @port, Queuer) do |conn| conn.beanstalks = beanstalks conn.app = app conn.backend = backend conn.logger = logger end end |