module Sequel::ServerLogging

  1. lib/sequel/extensions/server_logging.rb

Methods

Public Class

  1. extended

Public Instance

  1. connect
  2. disconnect_connection

Public Class methods

extended(db)

Initialize the hash mapping connections to shards, and turn on logging of connection info unless it has specifically been turned off.

[show source]
   # File lib/sequel/extensions/server_logging.rb
30 def self.extended(db)
31   db.instance_exec do
32     @server_connection_map ||= {}
33     self.log_connection_info = true if log_connection_info.nil?
34   end
35 end

Public Instance methods

connect(server)

When setting up a new connection, associate the connection with the shard.

[show source]
   # File lib/sequel/extensions/server_logging.rb
39 def connect(server)
40   conn = super
41   Sequel.synchronize{@server_connection_map[conn] = server}
42   conn
43 end
disconnect_connection(conn)

When disconnecting a connection, remove the related connection from the mapping.

[show source]
   # File lib/sequel/extensions/server_logging.rb
46 def disconnect_connection(conn)
47   super
48 ensure
49   Sequel.synchronize{@server_connection_map.delete(conn)}
50 end