Class: MongoKeepAlive::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/keepalive.rb

Overview

Control handle returned by start_keep_alive.

Instance Method Summary collapse

Constructor Details

#initialize(client, thread) ⇒ Handle

Returns a new instance of Handle.



14
15
16
17
18
# File 'lib/keepalive.rb', line 14

def initialize(client, thread)
  @client = client
  @thread = thread
  @stopped = false
end

Instance Method Details

#stopObject

Stop the keep-alive loop and close the connection.



21
22
23
24
25
26
# File 'lib/keepalive.rb', line 21

def stop
  @stopped = true
  @thread.kill
  @client.close
  MongoKeepAlive.logger.info("[mongo-keepalive] Stopped and disconnected.")
end

#stopped?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/keepalive.rb', line 28

def stopped?
  @stopped
end