Class: NoSE::Proxy::ProxyBase

Inherits:
Object
  • Object
show all
Defined in:
lib/nose/proxy.rb

Overview

A proxy server to interpret our query language and implement query plans

Direct Known Subclasses

MysqlProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject (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

#startvoid

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

#stopvoid

This method returns an undefined value.

Stop accepting connections



53
54
55
# File 'lib/nose/proxy.rb', line 53

def stop
  @continue = false
end