Class: Gongren::Rails::Server
- Inherits:
-
Object
- Object
- Gongren::Rails::Server
- Defined in:
- lib/gongren/rails/server.rb
Class Method Summary collapse
-
.start(options = {}) ⇒ Object
A quick way to instantiate a server with some options.
-
.submit(name, unit) ⇒ Object
Submits a unit of work to the pool of workers.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
-
#start ⇒ Object
Starts the reactor / event loop.
Constructor Details
Class Method Details
.start(options = {}) ⇒ Object
A quick way to instantiate a server with some options.
26 27 28 |
# File 'lib/gongren/rails/server.rb', line 26 def self.start(={}) new().start end |
.submit(name, unit) ⇒ Object
Submits a unit of work to the pool of workers.
16 17 18 19 20 21 22 23 |
# File 'lib/gongren/rails/server.rb', line 16 def self.submit(name, unit) data = Marshal.dump(unit) # NOTE: mandatory => true means return an error if the message can't be routed immediately. # This would indicate a configuration error, as workers should build their queue and # bind them to the exchange on startup. topic.publish(data, :persistent => true, :mandatory => true, :routing_key => "unit.#{name}") end |
Instance Method Details
#start ⇒ Object
Starts the reactor / event loop.
31 32 33 34 35 |
# File 'lib/gongren/rails/server.rb', line 31 def start logger.info { "Gongren::Server #{Process.pid} starting" } Qusion.start(@options) self.class.control_topic # Instantiates the control topic, for later use end |