module Sequel::ServerLogging
Public Class Methods
extended(db)
click to toggle source
Initialize the hash mapping connections to shards, and turn on logging of connection info unless it has specifically been turned off.
# 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)
click to toggle source
When setting up a new connection, associate the connection with the shard.
Calls superclass method
# 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)
click to toggle source
When disconnecting a connection, remove the related connection from the mapping.
Calls superclass method
# 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
Private Instance Methods
connection_info(conn)
click to toggle source
Include the server with the connection’s id.
# File lib/sequel/extensions/server_logging.rb 55 def connection_info(conn) 56 "(conn: #{conn.__id__}, server: #{Sequel.synchronize{@server_connection_map[conn]}}) " 57 end