Class: KingKong::Processor::Cube
- Includes:
- Logging
- Defined in:
- lib/kingkong/processor.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#process(ping, name) ⇒ Object
TODO use web sockets …
Methods included from Logging
Methods inherited from Base
Constructor Details
This class inherits a constructor from KingKong::Processor::Base
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
46 47 48 |
# File 'lib/kingkong/processor.rb', line 46 def url @url end |
Instance Method Details
#process(ping, name) ⇒ Object
TODO use web sockets …
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kingkong/processor.rb', line 49 def process(ping, name) http = EM::HttpRequest.new(url).post({ :body => Yajl::Encoder.encode([cube_hash(ping, name)]), :head => { 'content-type' => 'application/json' } }) http.callback{ case http.response_header.status when 200..204 logger.debug "Successfully reported to Cube at #{url}" else logger.error "Could not report to Cube server: HTTP #{http.response_header.status} : #{http.response}" end } http.errback{ logger.error "Could not connect to Cube at #{url}" } end |