Method: EM::Mongo::EMConnection#initialize

Defined in:
lib/em-mongo/connection.rb

#initialize(options = {}) ⇒ EMConnection

EM hooks



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/em-mongo/connection.rb', line 111

def initialize(options={})
  @request_id    = 0
  @retries       = 0
  @responses     = {}
  @is_connected  = false
  @host          = options[:host]        || DEFAULT_IP
  @port          = options[:port]        || DEFAULT_PORT
  @on_unbind     = options[:unbind_cb]   || proc {}
  @reconnect_in  = options[:reconnect_in]|| false
  @slave_ok      = options[:slave_ok]    || false

  @on_close = proc {
    raise Error, "failure with mongodb server #{@host}:#{@port}"
  }
  timeout options[:timeout] if options[:timeout]
  errback { @on_close.call }
end