Module: Carbon::Reader::ServerProtocol
- Includes:
- EventMachine::Protocols::LineText2
- Defined in:
- lib/carbon/reader.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #connection_completed ⇒ Object
- #initialize(queue, logger) ⇒ Object
- #next_action ⇒ Object
- #receive_data(data) ⇒ Object
- #receive_line(line) ⇒ Object
- #send_line(data) ⇒ Object
- #unbind ⇒ Object
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
43 44 45 |
# File 'lib/carbon/reader.rb', line 43 def logger @logger end |
Instance Method Details
#connection_completed ⇒ Object
83 84 85 |
# File 'lib/carbon/reader.rb', line 83 def connection_completed logger.info "Connected to CarbonServer" end |
#initialize(queue, logger) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/carbon/reader.rb', line 45 def initialize(queue,logger) set_delimiter ';' @queue = queue @callback = nil @logger = logger @queue.on_push do next_action() if @callback.nil? end end |
#next_action ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/carbon/reader.rb', line 67 def next_action() action = @queue.shift() return if action.nil? query = action[0] @callback = action[1] request = "get-metric #{query['path']} #{query['start']} #{query['end']}" send_line request end |
#receive_data(data) ⇒ Object
55 56 57 58 |
# File 'lib/carbon/reader.rb', line 55 def receive_data(data) #logger.debug "Carbon_server_connection got data: #{data}" super(data) end |
#receive_line(line) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/carbon/reader.rb', line 60 def receive_line(line) #logger.debug "Carbon_server_connection got line: #{line}" @callback[line] unless @callback.nil? @callback = nil next_action() end |
#send_line(data) ⇒ Object
78 79 80 81 |
# File 'lib/carbon/reader.rb', line 78 def send_line(data) #logger.debug "Carbon_server_connection sending line: #{data}" send_data "#{data};" end |
#unbind ⇒ Object
87 88 89 |
# File 'lib/carbon/reader.rb', line 87 def unbind logger.info "Closing CarbonServer connection" end |