Class: Store::Simple

Inherits:
Store
  • Object
show all
Defined in:
lib/store/simple.rb

Overview

“Simple” json feed of data. Sample implementation ./simple_endpoint.rb Assumes an endpoint for a list of metrics, and an endpoint to request data for a specific metric

This class can be used as a template for development of any custom classes to leverage JSON feeds of metrics

Instance Method Summary collapse

Constructor Details

#initialize(origin, settings) ⇒ Simple

Returns a new instance of Simple


7
8
9
10
# File 'lib/store/simple.rb', line 7

def initialize origin, settings
		super 
        @base_url = mandatory_param :url, "store_settings"
end

Instance Method Details

#get_metric(m, start = nil, stop = nil, step = nil) ⇒ Object

Return the raw data from the metric endpoint


32
33
34
35
# File 'lib/store/simple.rb', line 32

def get_metric m, start=nil, stop=nil, step=nil
	uri = get_metric_url m, start, stop, step
	json_metrics uri
end

#get_metric_url(m, start = nil, stop = nil, step = nil) ⇒ Object

Build a basic query for the metric data


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/store/simple.rb', line 18

def get_metric_url m, start=nil, stop=nil, step=nil
		query = []
		query << "start=#{start}"
		query << "stop=#{stop}"
		query << "step=#{step}"

		query_string = "?" + query.join("&")

		uri = "#{@base_url}/source/#{m.metric_id}#{query_string}"

		return uri
end

#get_metrics_listObject

Return the raw list of metrics from the endpoint listing


13
14
15
# File 'lib/store/simple.rb', line 13

def get_metrics_list
		json_metrics_list "#{@base_url}/source_list"
end