Class: MysqlPause::Backend
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- MysqlPause::Backend
- Defined in:
- lib/mysql-pause/backend.rb
Instance Method Summary collapse
-
#initialize(proxy) ⇒ Backend
constructor
A new instance of Backend.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(proxy) ⇒ Backend
Returns a new instance of Backend.
5 6 7 8 |
# File 'lib/mysql-pause/backend.rb', line 5 def initialize(proxy) @proxy = proxy @logger = proxy.logger end |
Instance Method Details
#post_init ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mysql-pause/backend.rb', line 10 def post_init if (peername = get_peername) @connect_from = Socket.unpack_sockaddr_in(peername) end if @proxy and @proxy.[:debug] port, ip = @connect_from @logger.debug("backend: connect from #{ip}:#{port}") end end |
#receive_data(data) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/mysql-pause/backend.rb', line 28 def receive_data(data) if not @proxy or @proxy.error? @logger.info("backend: proxy connection error: #{data.inspect}") close_proxy_connection close_connection_after_writing else @proxy.send_data(data) end end |
#unbind ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mysql-pause/backend.rb', line 21 def unbind if @proxy and @proxy.[:debug] port, ip = @connect_from @logger.debug("backend: unbind connection from #{ip}:#{port}") end end |