Class: Server::EventServer
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Server::EventServer
- Includes:
- Checker
- Defined in:
- lib/apprentice/server.rb
Overview
The actual EM::Connection instance referenced by the EventServer class. Notice that we use Mysql2::Client::EM instead of the regular Mysql2::Client class.
Constant Summary
Constants included from Checker
Instance Method Summary collapse
-
#initialize(options) ⇒ EventServer
constructor
:nodoc:.
-
#receive_data(data) ⇒ Object
Take the raw data received on @port and run initiate the checks against the server located at @server.
Methods included from Checker
#format_text, #generate_response
Constructor Details
#initialize(options) ⇒ EventServer
:nodoc:
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/apprentice/server.rb', line 11 def initialize() #:nodoc: @ip = .ip @port = .port @sql_port = .sql_port @server = .server @user = .user @password = .password @donor_allowed = .donor_allowed @type = .type @threshold = .threshold @status = {} end |
Instance Method Details
#receive_data(data) ⇒ Object
Take the raw data received on @port and run initiate the checks against the server located at @server
Special conditions
We are sending something to our client with #send_data inside the function, depending on what #run_checks returned to us during the function call.
Attributes
-
data
- We receive the actual HTTP request but since we’re not a full blown HTTP server we don’t actually use it to any extent
33 34 35 36 37 |
# File 'lib/apprentice/server.rb', line 33 def receive_data(data) response = run_checks response_text = format_text(response[:text]) send_data generate_response(response[:code], response_text) end |