bearcat 1.5.0.beta2 → 1.5.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eebb8dddf4346967e2667d229aaeb7f6f8e952d179374fd031409ceaf454f162
4
- data.tar.gz: fd7aa76b7318d0d884efc2e33551c3cee467ccbf81c4a8497e6c83dd4d2e3664
3
+ metadata.gz: 5ce46eee834b48d1cdcf925b6d4894b3852a963542c6ba4f3675a2abce0b4e42
4
+ data.tar.gz: a2f0cf50121f5fe2ae41a6ffcecff2ef69dbdebcf028250fc2300e2f60eb9e85
5
5
  SHA512:
6
- metadata.gz: b22779cb1c4ded1d20efb675c0d554ddbc4ad773d5708b5ef3729bdc49fc5bbff9b82f4cb004fcef28a31d9648024e9fbf5a98295ba9ab7630c9c7daa28b0c80
7
- data.tar.gz: 4b135c91ed60ba46adbcb4035940afc33b862f1bb1b623c2bda7a0adfc4d907f63298be9419b7af23f79b69127d3f94a100dd931360cdf533b6bf8de4a70407a
6
+ metadata.gz: 4070053e47e7b13cb78cebf9e33b6729d9702fa095dbcd02144b1383a705a8d8319c6cafda1bd20db23703a545569f54c5717fcbfa710bd353d971a186e91c4b
7
+ data.tar.gz: 463cc154f6d8df0fccd3cfaf4e571f5110e5712572db3a1313455319b055076bd6fd93f558a21bc0bb0daa54956c095243fa4be2fdb73def7085b8704d879009
data/bearcat.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.summary = %q{Canvas API}
18
18
 
19
19
  gem.files = %w[Rakefile bearcat.gemspec]
20
- gem.files += Dir.glob("lib/**/*.rb")
20
+ gem.files += Dir.glob("lib/**/*")
21
21
  gem.files += Dir.glob("spec/**/*")
22
22
  gem.test_files = Dir.glob("spec/**/*")
23
23
  gem.name = "bearcat"
@@ -0,0 +1,11 @@
1
+ #!lua name=bearcat_rate_limiting
2
+
3
+ local function checkin_time(keys, args)
4
+ local return_time = args[1]
5
+ local true_remaining = args[2]
6
+
7
+ local hash = keys[1]
8
+ return redis.call('HGET', hash, '_last_modified_')
9
+ end
10
+
11
+ redis.register_function('my_hset', my_hset)
@@ -0,0 +1,33 @@
1
+ local cache_key = KEYS[1]
2
+
3
+ local amount = tonumber(ARGV[1])
4
+ local current_time = tonumber(ARGV[2])
5
+ local outflow = tonumber(ARGV[3])
6
+ local maximum = tonumber(ARGV[4])
7
+
8
+ local leak = function(count, last_touched, current_time, outflow)
9
+ if count > 0 then
10
+ local timespan = current_time - last_touched
11
+ local loss = outflow * timespan
12
+ if loss > 0 then
13
+ count = count - loss
14
+ end
15
+ end
16
+ return count, last_touched
17
+ end
18
+
19
+ local count, last_touched = unpack(redis.call('HMGET', cache_key, 'count', 'timestamp'))
20
+ count = tonumber(count or 0)
21
+ last_touched = tonumber(last_touched or current_time)
22
+
23
+ count, last_touched = leak(count, last_touched, current_time, outflow)
24
+ if count < 0 then count = 0 end
25
+
26
+ count = count + amount
27
+ if count < 0 then count = 0 end
28
+ if count > maximum then count = maximum end
29
+
30
+ redis.call('HMSET', cache_key, 'count', count, 'timestamp', current_time)
31
+ redis.call('EXPIRE', cache_key, 600)
32
+
33
+ return { tostring(count), tostring(current_time) }
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '1.5.0.beta2' unless defined?(Bearcat::VERSION)
2
+ VERSION = '1.5.0.beta4' unless defined?(Bearcat::VERSION)
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module Catalogcat
2
2
  class Client < Footrest::Client
3
- module Courses
3
+ module Certificates
4
4
  def create_certificate(params = {})
5
5
  post('/api/v1/certificates', params)
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.beta2
4
+ version: 1.5.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Mills, Jake Sorce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -180,6 +180,8 @@ files:
180
180
  - lib/bearcat/client/users.rb
181
181
  - lib/bearcat/client_module.rb
182
182
  - lib/bearcat/rate_limiting.rb
183
+ - lib/bearcat/rate_limiting/functions.lua
184
+ - lib/bearcat/rate_limiting/increment_bucket.lua
183
185
  - lib/bearcat/rate_limiting/redis_script.rb
184
186
  - lib/bearcat/spec_helpers.rb
185
187
  - lib/bearcat/version.rb