Class: FnordMetric::API
- Inherits:
-
Object
- Object
- FnordMetric::API
- Defined in:
- lib/fnordmetric/api.rb
Constant Summary collapse
- @@opts =
nil
Instance Method Summary collapse
- #connect ⇒ Object
- #disconnect ⇒ Object
- #event(event_data) ⇒ Object
-
#initialize(opts = {}) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(opts = {}) ⇒ API
Returns a new instance of API.
5 6 7 8 |
# File 'lib/fnordmetric/api.rb', line 5 def initialize(opts={}) @@opts = FnordMetric.(opts) connect end |
Instance Method Details
#connect ⇒ Object
10 11 12 |
# File 'lib/fnordmetric/api.rb', line 10 def connect @redis = Redis.connect(:url => @@opts[:redis_url]) end |
#disconnect ⇒ Object
28 29 30 |
# File 'lib/fnordmetric/api.rb', line 28 def disconnect @redis.quit end |
#event(event_data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fnordmetric/api.rb', line 14 def event(event_data) begin if event_data.is_a?(Hash) event_data = event_data.to_json else JSON.parse(event_data) # void ;) end rescue JSON::ParserError FnordMetric.log("event_lost: can't parse json") else push_event(get_next_uuid, event_data) end end |