Class: Gongren::Server
- Inherits:
-
Object
- Object
- Gongren::Server
- Defined in:
- lib/gongren/server.rb
Overview
This version is intimately tied to Rails.
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
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
7 8 9 10 |
# File 'lib/gongren/server.rb', line 7 def initialize(={}) @options = .inject(Hash.new) {|memo, (k,v)| memo[k.to_sym] = v; memo} # #symbolize_keys @logger = [:logger] || Logger.new([:log] || STDERR) end |
Class Method Details
.start(options = {}) ⇒ Object
A quick way to instantiate a server with some options.
19 20 21 |
# File 'lib/gongren/server.rb', line 19 def self.start(={}) new().start end |
.submit(name, unit) ⇒ Object
Submits a unit of work to the pool of workers.
13 14 15 16 |
# File 'lib/gongren/server.rb', line 13 def self.submit(name, unit) data = Marshal.dump(unit) topic.publish(data, :persistent => true, :key => "unit.#{name}") end |
Instance Method Details
#start ⇒ Object
Starts the reactor / event loop.
24 25 26 27 28 |
# File 'lib/gongren/server.rb', line 24 def start logger.info { "Gongren::Server #{Process.pid} starting" } Qusion.start(@options) self.class.control_topic # Instantiates the control topic, for later use end |