Class: EM::Mongo::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/em-synchrony/em-mongo.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = DEFAULT_IP, port = DEFAULT_PORT, timeout = nil, opts = {}) ⇒ Connection

Returns a new instance of Connection.



30
31
32
33
34
35
36
37
38
39
# File 'lib/em-synchrony/em-mongo.rb', line 30

def initialize(host = DEFAULT_IP, port = DEFAULT_PORT, timeout = nil, opts = {})
  f = Fiber.current

  @em_connection = EMConnection.connect(host, port, timeout, opts)
  @db = {}

  # establish connection before returning
  EM.next_tick { f.resume }
  Fiber.yield
end