rollie 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: e7dca59b24d14a1f68bc1e52eb8de74ca2fdb10c
4
- data.tar.gz: c76e6ef7af25f4b7237c51ab794d2bfbe00eeaf5
2
+ SHA256:
3
+ metadata.gz: f6e0f59a08393e6f0955646fc41f0598b65cccb7d45d1b0ded22c30806bfd2e2
4
+ data.tar.gz: 209a877efa2dcef64db8c0f63099af0c029e31db39dea4cc13b228d1c5f0ab1d
5
5
  SHA512:
6
- metadata.gz: de6be4c8f9b384cae1755668b217835e92255fc323abbbdf6a257bdc8237942e06c6e6c0714ed2f4a9a33b7598c4d90030f2081fbe66d05d2968dcbad0ef91ae
7
- data.tar.gz: 379cb65364722e9182b736e61430d6dd8c50daaa45eee19538040f35b1501195b5c13c0c6c405e70df787399f9eb25ab0e300cd782b97d24d40a9289a92d1b0e
6
+ metadata.gz: bc2a3c339d26f054d44f20b331643932c13330767e0e53a1ae2ecdf8b92dff64cdd4eecc6c93f62147857a145bd9b56d1c91eeca8cd5037af1f0f389fc95e538
7
+ data.tar.gz: 5fed3ce9dd06e6b85e1e17cba4f92a2cb17ae448de79f7e83b22831ebcad42e17cdd64a1eca82acf9a202e2d450ecff75f55de90aa53ddc6d7651877d726e92d
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: CI
3
+ on:
4
+ push:
5
+ tags: ['v*']
6
+ branches: [master]
7
+ pull_request:
8
+ branches: ['**']
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
16
+ services:
17
+ redis:
18
+ image: redis
19
+ ports:
20
+ - 6379:6379
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ - run: bundle exec rspec --format doc
28
+ - run: bin/check-version
29
+
30
+ release:
31
+ needs: test
32
+ if: startsWith(github.ref, 'refs/tags/v')
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - uses: dawidd6/action-publish-gem@v1
37
+ with:
38
+ api_key: ${{secrets.RUBYGEMS_API_KEY}}
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1
4
+
5
+ * Remove maximum dependency versions
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  * fix for intervals < 1000 ms
@@ -9,4 +13,4 @@
9
13
 
10
14
  ## 0.0.1
11
15
 
12
- * Initial release
16
+ * Initial release
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # Rollie
2
2
 
3
- [![Build Status](https://travis-ci.org/zldavis/rollie.svg?branch=master)](https://travis-ci.org/zldavis/rollie)
3
+ ![CI](https://github.com/ParentSquare/rollie/workflows/CI/badge.svg)
4
4
 
5
5
  Rollie is a multi-purpose, fast, redis backed rate limiter that can be used to limit requests to external APIs, in Rack
6
6
  middleware, etc. Rollie uses a dedicated redis connection pool implemented using `connection_pool` for more efficient
7
- redis connection management.
8
-
7
+ redis connection management. The redis algorithm was inspired by the
8
+ [rolling-rate-limiter](https://www.npmjs.com/package/rolling-rate-limiter) node package.
9
+
9
10
  The key implementation detail is that Rollie utilizes a rolling window to bucket invocations in. Meaning, if you set
10
11
  a limit of 100 per 30 seconds, Rollie will start the clock in instant it is first executed with a given key.
11
-
12
+
12
13
  For example, first execution:
13
14
  ```
14
15
  rollie = Rollie::RateLimiter.new("api", limit: 10, interval: 30000)
@@ -91,4 +92,4 @@ Rollie.redis = {
91
92
  }
92
93
  ```
93
94
 
94
- If using rails, create an initializer `config/initializers/rollie.rb` with these settings.
95
+ If using rails, create an initializer `config/initializers/rollie.rb` with these settings.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ tag="$(git describe --abbrev=0 2>/dev/null || echo)"
6
+ echo "Tag: ${tag}"
7
+ tag="${tag#v}"
8
+ echo "Git Version: ${tag}"
9
+ [ "$tag" = '' ] && exit 0
10
+ gem_version="$(ruby -r ./lib/rollie/version -e "puts Rollie::VERSION" | tail -n1)"
11
+ echo "Gem Version: ${gem_version}"
12
+
13
+ tag_gt_version="$(ruby -r ./lib/rollie/version -e "puts Gem::Version.new(Rollie::VERSION) >= Gem::Version.new('${tag}')" | tail -n1)"
14
+ test "$tag_gt_version" = true
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -1,3 +1,3 @@
1
1
  module Rollie
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
@@ -9,16 +9,16 @@ Gem::Specification.new do |s|
9
9
  s.summary = "Generic rate limiter backed by Redis for efficient limiting using sliding windows."
10
10
  s.description = s.summary
11
11
 
12
- s.authors = ["Zach Davis"]
13
- s.email = "zldavis@gmail.com"
14
- s.homepage = "https://github.com/zldavis/rollie"
12
+ s.authors = ["Zach Davis", "Justin Howard"]
13
+ s.email = "justin.howard@parentsquare.com"
14
+ s.homepage = "https://github.com/ParentSquare/rollie"
15
15
 
16
16
  s.files = `git ls-files -z`.split("\x0")
17
17
  s.test_files = `git ls-files -- test/*`.split("\n")
18
18
 
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency "redis", "~> 3.2", ">= 3.2.1"
22
- s.add_dependency "redis-namespace", "~> 1.5", ">= 1.5.2"
23
- s.add_dependency "connection_pool", "~> 2.2", ">= 2.2.0"
21
+ s.add_dependency "redis", ">= 3.2.1"
22
+ s.add_dependency "redis-namespace", ">= 1.5.2"
23
+ s.add_dependency "connection_pool", ">= 2.2.0"
24
24
  end
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require "securerandom"
2
3
 
3
4
  module Rollie
4
5
  describe RateLimiter do
@@ -52,7 +53,7 @@ module Rollie
52
53
  @r.within_limit do
53
54
  count += 1
54
55
  end
55
- sleep 0.004
56
+ sleep 0.0045
56
57
  end
57
58
  expect(count).to eq(20)
58
59
  end
metadata CHANGED
@@ -1,22 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Davis
8
+ - Justin Howard
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
12
+ date: 2020-12-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: redis
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.2'
20
18
  - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 3.2.1
@@ -24,9 +22,6 @@ dependencies:
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.2'
30
25
  - - ">="
31
26
  - !ruby/object:Gem::Version
32
27
  version: 3.2.1
@@ -34,9 +29,6 @@ dependencies:
34
29
  name: redis-namespace
35
30
  requirement: !ruby/object:Gem::Requirement
36
31
  requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.5'
40
32
  - - ">="
41
33
  - !ruby/object:Gem::Version
42
34
  version: 1.5.2
@@ -44,9 +36,6 @@ dependencies:
44
36
  prerelease: false
45
37
  version_requirements: !ruby/object:Gem::Requirement
46
38
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.5'
50
39
  - - ">="
51
40
  - !ruby/object:Gem::Version
52
41
  version: 1.5.2
@@ -54,9 +43,6 @@ dependencies:
54
43
  name: connection_pool
55
44
  requirement: !ruby/object:Gem::Requirement
56
45
  requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '2.2'
60
46
  - - ">="
61
47
  - !ruby/object:Gem::Version
62
48
  version: 2.2.0
@@ -64,27 +50,26 @@ dependencies:
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '2.2'
70
53
  - - ">="
71
54
  - !ruby/object:Gem::Version
72
55
  version: 2.2.0
73
56
  description: Generic rate limiter backed by Redis for efficient limiting using sliding
74
57
  windows.
75
- email: zldavis@gmail.com
58
+ email: justin.howard@parentsquare.com
76
59
  executables: []
77
60
  extensions: []
78
61
  extra_rdoc_files: []
79
62
  files:
63
+ - ".github/workflows/ci.yml"
80
64
  - ".gitignore"
81
65
  - ".rspec"
82
- - ".travis.yml"
83
66
  - CHANGELOG.md
84
67
  - Gemfile
85
68
  - LICENSE
86
69
  - README.md
87
70
  - Rakefile
71
+ - bin/check-version
72
+ - bin/rspec
88
73
  - lib/rollie.rb
89
74
  - lib/rollie/rate_limiter.rb
90
75
  - lib/rollie/redis_pool.rb
@@ -94,7 +79,7 @@ files:
94
79
  - spec/rollie/rate_limiter_spec.rb
95
80
  - spec/rollie_spec.rb
96
81
  - spec/spec_helper.rb
97
- homepage: https://github.com/zldavis/rollie
82
+ homepage: https://github.com/ParentSquare/rollie
98
83
  licenses:
99
84
  - MIT
100
85
  metadata: {}
@@ -114,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
99
  version: '0'
115
100
  requirements: []
116
101
  rubyforge_project:
117
- rubygems_version: 2.5.2
102
+ rubygems_version: 2.7.6
118
103
  signing_key:
119
104
  specification_version: 4
120
105
  summary: Generic rate limiter backed by Redis for efficient limiting using sliding
@@ -1,3 +0,0 @@
1
- language: ruby
2
- services:
3
- - redis-server