class RR::DatabaseProxy
The proxy to a remote database connection
Constants
- DEFAULT_PORT
Default tcp port to listen on
Attributes
session_register[RW]
A simple Hash to hold Session object Purpose: preventing them from being garbage collected when they are only referenced through Drb
Public Class Methods
new()
click to toggle source
# File lib/rubyrep/database_proxy.rb, line 22 def initialize self.session_register = {} end
Public Instance Methods
create_session(config)
click to toggle source
Create a ProxyConnection according to
provided configuration Hash. config
is a hash as described by
ActiveRecord::Base#establish_connection
# File lib/rubyrep/database_proxy.rb, line 28 def create_session(config) session = ProxyConnection.new config self.session_register[session] = session session end
destroy_session(session)
click to toggle source
Destroys the given session from the session register
# File lib/rubyrep/database_proxy.rb, line 35 def destroy_session(session) session.destroy session_register.delete session end
ping()
click to toggle source
Returns 'pong'. Used to verify that a working proxy is running.
# File lib/rubyrep/database_proxy.rb, line 41 def ping 'pong' end
terminate!()
click to toggle source
Terminates this proxy
# File lib/rubyrep/database_proxy.rb, line 46 def terminate! # AL: The only way I could find to kill the main thread from a sub thread Thread.main.raise SystemExit end