Class: Server::EventServer
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Server::EventServer
- Includes:
- Checker
- Defined in:
- lib/apprentice/server.rb
Constant Summary
Constants included from Checker
Checker::CODES, Checker::STATES
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(options) ⇒ EventServer
constructor
A new instance of EventServer.
- #receive_data(data) ⇒ Object
Methods included from Checker
#format_text, #generate_response
Methods included from Galera
#check_cluster_size, #check_local_state, #check_ready_state, #get_galera_status, #run_checks
Constructor Details
#initialize(options) ⇒ EventServer
Returns a new instance of EventServer.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apprentice/server.rb', line 9 def initialize() @ip = .ip @port = .port @sql_port = .sql_port @server = .server @user = .user @password = .password @donor_allowed = .donor_allowed @status = {} begin @client = Mysql2::Client.new( host: @server, port: @sql_port, username: @user, password: @password, as: :array, reconnect: true ) rescue Exception => puts EM.stop_server end end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/apprentice/server.rb', line 7 def client @client end |
Instance Method Details
#receive_data(data) ⇒ Object
34 35 36 37 38 |
# File 'lib/apprentice/server.rb', line 34 def receive_data(data) response = run_checks response_text = format_text(response[:text]) send_data generate_response(response[:code], response_text) end |