Class: Mongrel2::Connection
- Inherits:
-
Object
- Object
- Mongrel2::Connection
- Defined in:
- lib/mongrel2/connection.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(uuid, sub, pub) ⇒ Connection
constructor
A new instance of Connection.
- #recv ⇒ Object
- #reply(req, body, status = 200, headers = {}) ⇒ Object
Constructor Details
#initialize(uuid, sub, pub) ⇒ Connection
Returns a new instance of Connection.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mongrel2/connection.rb', line 13 def initialize(uuid, sub, pub) @uuid, @sub, @pub = uuid, sub, pub # Connect to receive requests @reqs = self.class.context.socket(ZMQ::PULL) @reqs.connect(sub) # Connect to send responses @resp = self.class.context.socket(ZMQ::PUB) @resp.connect(pub) @resp.setsockopt(ZMQ::IDENTITY, uuid) end |
Class Method Details
.context ⇒ Object
9 10 11 |
# File 'lib/mongrel2/connection.rb', line 9 def self.context @context ||= ZMQ::Context.new(1) end |
Instance Method Details
#close ⇒ Object
37 38 39 40 |
# File 'lib/mongrel2/connection.rb', line 37 def close # I think I should be able to just close the context self.class.context.close rescue nil end |