atsd 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/atsd/models/base_model.rb +17 -0
- data/lib/atsd/models/series.rb +0 -11
- data/lib/atsd/queries/series_query.rb +0 -14
- data/lib/atsd/services/series_service.rb +1 -1
- data/lib/atsd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe21d9c34f97de668d8afc76732e7e2c4afa8f3
|
4
|
+
data.tar.gz: 5ef52d69475fe575de5367e3a4bcf45932f5ea30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a72102988e12f9f580c679f556f433c05ae31809751d236ef7a70448999029a89224327732722ece0751ebed6ac7db3e0766e383697ae37a6b19b028102d45a
|
7
|
+
data.tar.gz: 37b3a82b25af1aa587020e4be9b506262b10f129b40a8a7889fc2b5e1fa3b813fe992077b616b7c0496e1057c137b4a73782bccd3464426d04b2aa8d2ed6f9bc
|
data/README.md
CHANGED
@@ -206,7 +206,7 @@ s = Series.new
|
|
206
206
|
s.entity = 'sensor-1'
|
207
207
|
s.metric = 'temperature'
|
208
208
|
s.data = [ {t: Time.now.to_i*1000, v: 22} ]
|
209
|
-
series_service.insert(s)
|
209
|
+
atsd.series_service.insert(s)
|
210
210
|
```
|
211
211
|
|
212
212
|
Inserting series using Sample class:
|
@@ -215,7 +215,7 @@ Inserting series using Sample class:
|
|
215
215
|
s = Series.new
|
216
216
|
s.entity = 'sensor-1'
|
217
217
|
s.metric = 'pressure'
|
218
|
-
sample = Sample.new :
|
218
|
+
sample = Sample.new :time => Time.parse("2015-11-17T17:00:00Z"), :value => 7, :version => {:status => "normal", :source => "gateway-1"}
|
219
219
|
s.data = [ sample ]
|
220
220
|
series_service.insert(s)
|
221
221
|
```
|
@@ -223,8 +223,8 @@ series_service.insert(s)
|
|
223
223
|
Inserting Series with Versions:
|
224
224
|
|
225
225
|
```ruby
|
226
|
-
sample_1 = Sample.new :
|
227
|
-
sample_2 = Sample.new :
|
226
|
+
sample_1 = Sample.new :time => Time.parse("2015-11-17T17:00:00Z"), :value => 7, :version => {:status => "normal", :source => "gateway-1"}
|
227
|
+
sample_2 = Sample.new :time => Time.parse("2015-11-17T18:00:00Z"), :value => 17, :version => {:status => "error", :source => "gateway-1"}
|
228
228
|
series = Series.new :entity => "sensor-1", :metric => "pressure", :data => [sample_1, sample_2]
|
229
229
|
atsd.series_service.insert(series)
|
230
230
|
```
|
@@ -20,6 +20,23 @@ module ATSD
|
|
20
20
|
end
|
21
21
|
hash
|
22
22
|
end
|
23
|
+
|
24
|
+
# Converts time and value keys as t and v respectively
|
25
|
+
# for the rest operates as a superclass method
|
26
|
+
def []=(key,value)
|
27
|
+
if key.to_s == 'time'
|
28
|
+
key = :t
|
29
|
+
case value
|
30
|
+
when Time
|
31
|
+
value = value.to_i * 1_000
|
32
|
+
else
|
33
|
+
value = value.to_i
|
34
|
+
end
|
35
|
+
end
|
36
|
+
key = :v if key.to_s == 'value'
|
37
|
+
super(key, value)
|
38
|
+
end
|
39
|
+
|
23
40
|
end
|
24
41
|
end
|
25
42
|
|
data/lib/atsd/models/series.rb
CHANGED
@@ -7,17 +7,6 @@ module ATSD
|
|
7
7
|
|
8
8
|
class Sample < BaseModel
|
9
9
|
|
10
|
-
TO_MILLISECONDS_LAMBDA = ->(v) do
|
11
|
-
case v
|
12
|
-
when Time
|
13
|
-
v.to_i * 1_000
|
14
|
-
else
|
15
|
-
v.to_i
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
coerce_key :t, TO_MILLISECONDS_LAMBDA
|
20
|
-
|
21
10
|
def set_time(time)
|
22
11
|
self["t"] = time
|
23
12
|
end
|
@@ -4,20 +4,6 @@ module ATSD
|
|
4
4
|
# Class for building and executing Series Query
|
5
5
|
# @see https://axibase.com/atsd/api/#series:-query
|
6
6
|
class SeriesQuery < BaseQuery
|
7
|
-
#
|
8
|
-
# # @!method type(type)
|
9
|
-
# # specifies source for underlying data
|
10
|
-
# # @param [String] type see {Type} for possible values
|
11
|
-
# # @return [self]
|
12
|
-
#
|
13
|
-
# TO_MILLISECONDS_LAMBDA = ->(v) do
|
14
|
-
# case v
|
15
|
-
# when Time
|
16
|
-
# v.to_i * 1_000
|
17
|
-
# else
|
18
|
-
# v.to_i
|
19
|
-
# end
|
20
|
-
# end
|
21
7
|
|
22
8
|
coerce_key :end_time, TO_MILLISECONDS_LAMBDA
|
23
9
|
coerce_key :start_time, TO_MILLISECONDS_LAMBDA
|
@@ -57,7 +57,7 @@ module ATSD
|
|
57
57
|
# Post json
|
58
58
|
# @param [Hash] config - Hash containing url, login and password keys, e.g. {:url => "http://www.example.com:8088/api/v1", :login => "login", :password => "password"}
|
59
59
|
# @param [String] payload Body - ready to be parsed by ATSD server
|
60
|
-
# @return
|
60
|
+
# @return [Faraday::Response]
|
61
61
|
# @raise [APIError]
|
62
62
|
def self.post_payload(config,payload)
|
63
63
|
url = config[:url]
|
data/lib/atsd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Axibase Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|