rapidity 0.0.6.88566 → 0.0.6.88627

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: f035f3525eab3c929a835208cd275212935d1052df051234b46a5240517d3c25
4
- data.tar.gz: 129798e61b0e40d402d18d1d5d80d2e2f1f05e99c53de2c0bec240774d0fda07
3
+ metadata.gz: 4812c1514ceb875e24c9c4a9b86ca1eaef1227eceb13f8b1ae7498c7579e6809
4
+ data.tar.gz: 0b812cebd0ed83cdfa35e52550d73b42fbabed89b60e771695c02cf0720d71e6
5
5
  SHA512:
6
- metadata.gz: eb39b54f19ee6d1bc89592aa9a03012c2e274452a72ff4e6bafdb629b614aa8401e5fbc1626f108b30d98f46e6b9a7bc498f2612cfa9cd0fd593d9c710e8e750
7
- data.tar.gz: 0043036ac0b0451f1a694f565b2149ecf88b9219a7997beb6a7ec9aa3e4b14be800c1e7e676747a4a3ec93ef21ce69fbba8110ea8f8a6ccedd28a61ce3374c7e
6
+ metadata.gz: b037c65bed50ed704dace8fcc16cfa554e39c810d72b9f1da7b430b2a1bad6f1d7799bfd2e0f8615ece8f45b6fa2457445e94f2996e3a1caac31d0f5b9ecac52
7
+ data.tar.gz: cb0ada7d5095aac7bd0c447f95d7de55628b6574cc7b07535ff548d64d3cf9dc640fa8d780772892dc59d4e90ad44d54cee1f4808799bda447929ef874677c1f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rapidity (0.0.6.88566)
4
+ rapidity (0.0.6)
5
5
  activesupport
6
6
  connection_pool
7
7
  redis
@@ -9,13 +9,12 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.1.3.2)
12
+ activesupport (7.0.3)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- zeitwerk (~> 2.3)
18
- addressable (2.7.0)
17
+ addressable (2.8.0)
19
18
  public_suffix (>= 2.0.2, < 5.0)
20
19
  ansi (1.5.0)
21
20
  ast (2.4.2)
@@ -28,62 +27,60 @@ GEM
28
27
  byebug (11.1.3)
29
28
  coercible (1.0.0)
30
29
  descendants_tracker (~> 0.0.1)
31
- concurrent-ruby (1.1.8)
30
+ concurrent-ruby (1.1.10)
32
31
  connection_pool (2.2.5)
33
32
  descendants_tracker (0.0.4)
34
33
  thread_safe (~> 0.3, >= 0.3.1)
35
- diff-lcs (1.4.4)
34
+ diff-lcs (1.5.0)
36
35
  docile (1.4.0)
37
36
  equalizer (0.0.11)
38
- erubis (2.7.0)
39
- flay (2.12.1)
40
- erubis (~> 2.7.0)
37
+ erubi (1.10.0)
38
+ flay (2.13.0)
39
+ erubi (~> 1.10)
41
40
  path_expander (~> 1.0)
42
41
  ruby_parser (~> 3.0)
43
42
  sexp_processor (~> 4.0)
44
- flog (4.6.4)
43
+ flog (4.6.5)
45
44
  path_expander (~> 1.0)
46
45
  ruby_parser (~> 3.1, > 3.1.0)
47
46
  sexp_processor (~> 4.8)
48
- i18n (1.8.10)
47
+ i18n (1.10.0)
49
48
  concurrent-ruby (~> 1.0)
50
49
  ice_nine (0.11.2)
51
50
  kwalify (0.7.2)
52
51
  launchy (2.5.0)
53
52
  addressable (~> 2.7)
54
- minitest (5.14.4)
55
- parser (3.0.1.1)
53
+ minitest (5.16.1)
54
+ parser (3.1.2.0)
56
55
  ast (~> 2.4.1)
57
56
  path_expander (1.1.0)
58
- psych (3.3.2)
59
- public_suffix (4.0.6)
60
- rainbow (3.0.0)
57
+ public_suffix (4.0.7)
58
+ rainbow (3.1.1)
61
59
  redis (4.7.0)
62
- reek (6.0.4)
60
+ reek (6.1.1)
63
61
  kwalify (~> 0.7.0)
64
- parser (~> 3.0.0)
65
- psych (~> 3.1)
62
+ parser (~> 3.1.0)
66
63
  rainbow (>= 2.0, < 4.0)
67
- rspec (3.10.0)
68
- rspec-core (~> 3.10.0)
69
- rspec-expectations (~> 3.10.0)
70
- rspec-mocks (~> 3.10.0)
64
+ rspec (3.11.0)
65
+ rspec-core (~> 3.11.0)
66
+ rspec-expectations (~> 3.11.0)
67
+ rspec-mocks (~> 3.11.0)
71
68
  rspec-collection_matchers (1.2.0)
72
69
  rspec-expectations (>= 2.99.0.beta1)
73
- rspec-core (3.10.1)
74
- rspec-support (~> 3.10.0)
75
- rspec-expectations (3.10.1)
70
+ rspec-core (3.11.0)
71
+ rspec-support (~> 3.11.0)
72
+ rspec-expectations (3.11.0)
76
73
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.10.0)
78
- rspec-mocks (3.10.2)
74
+ rspec-support (~> 3.11.0)
75
+ rspec-mocks (3.11.1)
79
76
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.10.0)
81
- rspec-support (3.10.2)
82
- rspec_junit_formatter (0.4.1)
77
+ rspec-support (~> 3.11.0)
78
+ rspec-support (3.11.0)
79
+ rspec_junit_formatter (0.5.1)
83
80
  rspec-core (>= 2, < 4, != 2.12.0)
84
- ruby_parser (3.16.0)
85
- sexp_processor (~> 4.15, >= 4.15.1)
86
- rubycritic (4.6.1)
81
+ ruby_parser (3.19.1)
82
+ sexp_processor (~> 4.16)
83
+ rubycritic (4.7.0)
87
84
  flay (~> 2.8)
88
85
  flog (~> 4.4)
89
86
  launchy (>= 2.0.0)
@@ -94,9 +91,9 @@ GEM
94
91
  simplecov (>= 0.17.0)
95
92
  tty-which (~> 0.4.0)
96
93
  virtus (~> 1.0)
97
- sexp_processor (4.15.3)
98
- shoulda-matchers (4.5.1)
99
- activesupport (>= 4.2.0)
94
+ sexp_processor (4.16.1)
95
+ shoulda-matchers (5.1.0)
96
+ activesupport (>= 5.2.0)
100
97
  simplecov (0.21.2)
101
98
  docile (~> 1.1)
102
99
  simplecov-html (~> 0.11)
@@ -106,21 +103,20 @@ GEM
106
103
  simplecov
107
104
  terminal-table
108
105
  simplecov-html (0.12.3)
109
- simplecov_json_formatter (0.1.3)
110
- terminal-table (3.0.1)
106
+ simplecov_json_formatter (0.1.4)
107
+ terminal-table (3.0.2)
111
108
  unicode-display_width (>= 1.1.1, < 3)
112
109
  thread_safe (0.3.6)
113
110
  timeouter (0.1.3.38794)
114
111
  tty-which (0.4.2)
115
112
  tzinfo (2.0.4)
116
113
  concurrent-ruby (~> 1.0)
117
- unicode-display_width (2.0.0)
114
+ unicode-display_width (2.2.0)
118
115
  virtus (1.0.5)
119
116
  axiom-types (~> 0.1)
120
117
  coercible (~> 1.0)
121
118
  descendants_tracker (~> 0.0, >= 0.0.3)
122
119
  equalizer (~> 0.0, >= 0.0.9)
123
- zeitwerk (2.4.2)
124
120
 
125
121
  PLATFORMS
126
122
  ruby
@@ -41,13 +41,18 @@ module Rapidity
41
41
  end
42
42
  end
43
43
 
44
- def obtain(count = 5)
44
+ def obtain(count = 5, with_time: false)
45
+ time = nil
45
46
  @limiters.each do |limiter|
46
- count = limiter.obtain(count)
47
+ count, time = limiter.obtain(count, with_time: with_time)
47
48
  break if count == 0
48
49
  end
49
50
 
50
- count
51
+ if with_time
52
+ [count, time]
53
+ else
54
+ count
55
+ end
51
56
  end
52
57
 
53
58
  end
@@ -1,6 +1,9 @@
1
1
  -- args: key, treshold, interval, count
2
2
  -- returns: obtained count.
3
3
 
4
+ -- this is required to be able to use TIME and writes; basically it lifts the script into IO
5
+ redis.replicate_commands()
6
+
4
7
  -- make some nicer looking variable names:
5
8
  local retval = nil
6
9
 
@@ -17,6 +20,7 @@ local count = tonumber(ARGV[3])
17
20
  local current = 0
18
21
  local to_return = 0
19
22
 
23
+ local redis_time = redis.call("TIME") -- Array of [seconds, microseconds]
20
24
  redis.call("SET", key, treshold, "EX", interval, "NX")
21
25
  current = redis.call("DECRBY", key, count)
22
26
 
@@ -34,4 +38,4 @@ else
34
38
  retval = count
35
39
  end
36
40
 
37
- return retval
41
+ return {retval, redis_time}
@@ -40,8 +40,10 @@ module Rapidity
40
40
  end
41
41
 
42
42
  # Obtain values from counter
43
+ # @params count - try to obtain 'tokens'
44
+ # @params with_time - return or not Redis-service time at which request processed
43
45
  # @return count succesfuly obtained send slots
44
- def obtain(count = 5)
46
+ def obtain(count = 5, with_time: false)
45
47
  count = count.abs
46
48
 
47
49
  result = begin
@@ -59,7 +61,8 @@ module Rapidity
59
61
  end
60
62
  end
61
63
 
62
- taken = result.to_i
64
+ taken = result[0].to_i
65
+ time = Time.at(*result[1].map(&:to_i), :millisecond)
63
66
 
64
67
  if taken == 0
65
68
  ttl = @pool.with do |conn|
@@ -73,7 +76,11 @@ module Rapidity
73
76
  end
74
77
  end
75
78
 
76
- taken
79
+ if with_time
80
+ [taken, time]
81
+ else
82
+ taken
83
+ end
77
84
  end
78
85
 
79
86
  def ensure_script_loaded
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapidity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.88566
4
+ version: 0.0.6.88627
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yurusov Vlad