redistimeseries 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3de654187c79b461ca14b8d8ea7fe7be7262ab68c76999aaae7ca5d114aa067
4
- data.tar.gz: ea43a4257fcc410def290bfd33cc18be0851f3b95dc9fe3da5289060701027de
3
+ metadata.gz: a72e1a9e50a89524c4e4b7678b629d120fd41d918cd7c7e6d19fe90ad3d8f41e
4
+ data.tar.gz: 75fa47de22b1351321ddbb93b46ee7d51804fea64479c31ff84ad5f1b35b45b6
5
5
  SHA512:
6
- metadata.gz: 1d38aa78c9952bec3249dac3491d509fb2727ae85e0b9b7643f16b1fa43e302920bca6bdd0887e9c1a4830f2bafdee95d44ad570aa48026b79709596a3137b23
7
- data.tar.gz: 102afdfbc45b7ebfedf306023d89a062f50418b18743263f0cc4c72c5e1b57181c905c9608caae904e5930b8116ae665f67f85af46ce9470e571d6be13df7a22
6
+ metadata.gz: 9ad9e23e76fd204a3231c650faf74faee510f12809e705106919c85f970cb627181a98be94d018566d337c5e18f99069de03636c5117cead6156db4486b1024e
7
+ data.tar.gz: f660b37032c113a8dabfd1f9730c2390483dfe56828b6644fc1168ead9ad8d7bf9803f49d5359012e45e1b53b376d8cc81bc1c719694177f5e6c0d7580a3b88f
@@ -0,0 +1,48 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ gem ]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+ services:
12
+ redistimeseries:
13
+ image: redislabs/redistimeseries:latest
14
+ ports:
15
+ - 6379/tcp
16
+ # options: --entrypoint redis-server
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby 2.6
20
+ uses: actions/setup-ruby@v1
21
+ with:
22
+ version: 2.6.x
23
+ - name: Debug Info
24
+ env:
25
+ REDIS_PORT: ${{ job.services.redistimeseries.ports[6379] }}
26
+ run: |
27
+ sudo apt-get install redis-tools
28
+ redis-cli -p ${REDIS_PORT} info
29
+ redis-cli -p ${REDIS_PORT} TS.CREATE mytestkey
30
+ - name: Bundle install
31
+ run: |
32
+ gem install bundler:2.1.2
33
+ bundle install
34
+ - name: Run specs
35
+ env:
36
+ REDIS_URL: redis://localhost:${{ job.services.redistimeseries.ports[6379] }}
37
+ run: |
38
+ ./bin/rspec
39
+ - name: Publish to RubyGems
40
+ run: |
41
+ mkdir -p $HOME/.gem
42
+ touch $HOME/.gem/credentials
43
+ chmod 0600 $HOME/.gem/credentials
44
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
45
+ gem build *.gemspec
46
+ gem push *.gem
47
+ env:
48
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -1,10 +1,12 @@
1
- name: Ruby Gem
1
+ name: CI Build
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches: [ master ]
6
6
  pull_request:
7
7
  branches: [ master ]
8
+ schedule:
9
+ - cron: '0 0 * * *' # Nightly to cover cases where the server might breaks the client
8
10
 
9
11
  jobs:
10
12
  build:
@@ -38,13 +40,13 @@ jobs:
38
40
  REDIS_URL: redis://localhost:${{ job.services.redistimeseries.ports[6379] }}
39
41
  run: |
40
42
  ./bin/rspec
41
- - name: Publish to RubyGems
42
- run: |
43
- mkdir -p $HOME/.gem
44
- touch $HOME/.gem/credentials
45
- chmod 0600 $HOME/.gem/credentials
46
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
47
- gem build *.gemspec
48
- gem push *.gem
49
- env:
50
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
43
+ # - name: Publish to RubyGems
44
+ # run: |
45
+ # mkdir -p $HOME/.gem
46
+ # touch $HOME/.gem/credentials
47
+ # chmod 0600 $HOME/.gem/credentials
48
+ # printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
49
+ # gem build *.gemspec
50
+ # gem push *.gem
51
+ # env:
52
+ # GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- redistimeseries (0.1.1)
12
+ redistimeseries (0.1.2)
13
13
  redis (~> 4)
14
14
 
15
15
  GEM
data/README.md CHANGED
@@ -31,6 +31,7 @@ using Redistimeseries::RedisRefinement
31
31
  client = Redis.new
32
32
  client.ts_create(key: "mytimeseries")
33
33
  client.ts_add(key: "mytimeseries", value: 141)
34
+ client.ts_get("mytimeseries")
34
35
  ```
35
36
 
36
37
  # Methods - see redis_refinement.rb
@@ -20,8 +20,11 @@ module Redistimeseries
20
20
  _ts_call(cmd)
21
21
  end
22
22
 
23
- def ts_madd(key:, timestamp: "*", value:) # TODO make multi
24
- cmd = ['TS.MADD', key, timestamp, value]
23
+ # Usage:
24
+ # ts_madd([key, timestamp, value, key, timestamp, value])
25
+ # or ts_madd([[key, timestamp, value], [key, timestamp, value]])
26
+ def ts_madd(key_timestamp_values)
27
+ cmd = ['TS.MADD', *key_timestamp_values.flatten]
25
28
  _ts_call(cmd)
26
29
  end
27
30
 
@@ -29,40 +32,68 @@ module Redistimeseries
29
32
 
30
33
  def ts_decrby; end
31
34
 
32
- def ts_createrule; end
35
+ def ts_createrule(source_key:, dest_key:, aggregation_type:, timebucket:)
36
+ cmd = ["TS.CREATERULE", source_key, dest_key]
37
+ cmd += ["AGGREGATION", aggregation_type, timebucket]
38
+ _ts_call(cmd)
39
+ end
33
40
 
34
41
  def ts_deleterule; end
35
42
 
36
- def ts_range(key:, from: 0, to: nil, count: nil, aggtype: nil, timebucket: nil)
37
- to_time = to || (Time.now.to_f * 1000.0).to_i
38
- cmd = ['TS.RANGE', key, from, to_time]
39
- if count
40
- cmd += ['COUNT', count]
41
- else
42
- cmd += ['AGGREGATION', aggtype, timebucket]
43
- end
43
+ def ts_range(key:, from: '-', to: '+', count: nil, aggtype: nil, timebucket: nil)
44
+ cmd = ['TS.RANGE', key, from, to]
45
+ cmd += ['COUNT', count] if count
46
+ cmd += ['AGGREGATION', aggtype, timebucket] if aggtype && timebucket
44
47
  _ts_call(cmd)
45
48
  end
46
49
 
47
- def ts_mrange; end
50
+ def ts_mrange(from_timestamp:, to_timestamp:,
51
+ aggregation_type: nil, time_bucket: nil,
52
+ count: nil, with_labels: false, filters: [])
53
+
54
+ cmd = ["TS.MRANGE", from_timestamp, to_timestamp]
55
+ cmd += ["COUNT", count] if count
56
+
57
+ if aggregation_type && time_bucket
58
+ cmd += ["AGGREGATION", aggregation_type, time_bucket]
59
+ end
60
+
61
+ cmd += ["WITHLABELS"] if with_labels
62
+ cmd += ["FILTER", *filters] if filters.length.positive?
63
+
64
+ _ts_call(cmd)
65
+ end
48
66
 
49
- def ts_get; end
67
+ def ts_get(key)
68
+ cmd = ["TS.GET", key]
69
+ _ts_call(cmd)
70
+ end
50
71
 
51
- def ts_mget; end
72
+ def ts_mget(filters:, withlabels: false)
73
+ cmd = []
74
+ cmd += ["WITHLABELS"] if withlabels
75
+ cmd += ["FILTER", *filters]
76
+ _ts_call(cmd)
77
+ end
52
78
 
53
79
  def ts_info(key:)
54
80
  cmd = ["TS.INFO", key]
55
81
  _ts_call(cmd)
56
82
  end
57
83
 
58
- def ts_queryindex(filter:)
59
- cmd = ["TS.QUERYINDEX", filter]
84
+ def ts_queryindex(filters:)
85
+ cmd = ["TS.QUERYINDEX", *filters]
60
86
  _ts_call(cmd)
61
87
  end
62
88
 
63
- def _ts_call(cmd)
89
+ def _ts_call(args)
64
90
  # puts "CMD #{cmd.join(' ')}"
65
- call cmd
91
+ synchronize do |client|
92
+ res = client.call(args)
93
+ raise res.first if res.is_a?(Array) && res.first.is_a?(Redis::CommandError)
94
+
95
+ res
96
+ end
66
97
  end
67
98
  end
68
99
  end
@@ -1,3 +1,3 @@
1
1
  module Redistimeseries
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redistimeseries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eaden McKee (eadz)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/build.yml"
34
35
  - ".github/workflows/gempush.yml"
35
36
  - ".gitignore"
36
37
  - ".rspec"