Class: NoSE::Proxy::ProxyBase
Overview
A proxy server to interpret our query language and implement query plans
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#handle_connection(_socket) ⇒ void
abstract
:nocov:.
-
#initialize(config, result, backend) ⇒ ProxyBase
constructor
A new instance of ProxyBase.
-
#remove_connection(_socket) ⇒ void
abstract
:nocov:.
-
#start ⇒ void
Start the proxy server.
-
#stop ⇒ void
Stop accepting connections.
Constructor Details
#initialize(config, result, backend) ⇒ ProxyBase
Returns a new instance of ProxyBase.
9 10 11 12 13 14 15 16 17 |
# File 'lib/nose/proxy.rb', line 9 def initialize(config, result, backend) @logger = Logging.logger['nose::proxy'] @result = result @backend = backend @config = config @continue = true end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/nose/proxy.rb', line 8 def logger @logger end |
Instance Method Details
#handle_connection(_socket) ⇒ void
This method is abstract.
Subclasses should process a new connection on the given socket
This method returns an undefined value.
:nocov:
38 39 40 |
# File 'lib/nose/proxy.rb', line 38 def handle_connection(_socket) fail NotImplementedError end |
#remove_connection(_socket) ⇒ void
This method is abstract.
Subclasses should dispose of state associated with the socket
This method returns an undefined value.
:nocov:
46 47 48 |
# File 'lib/nose/proxy.rb', line 46 def remove_connection(_socket) fail NotImplementedError end |
#start ⇒ void
This method returns an undefined value.
Start the proxy server
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nose/proxy.rb', line 21 def start @logger.info "Starting server on port #{@config[:port]}" server_socket = TCPServer.new('127.0.0.1', @config[:port]) server_socket.listen(100) @read_sockets = [server_socket] @write_sockets = [] loop do break unless @continue && select_connection(server_socket) end end |
#stop ⇒ void
This method returns an undefined value.
Stop accepting connections
53 54 55 |
# File 'lib/nose/proxy.rb', line 53 def stop @continue = false end |