pecorino 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 +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/README.md +15 -4
- data/lib/pecorino/version.rb +1 -1
- metadata +4 -5
- data/Gemfile.lock +0 -156
- /data/lib/pecorino/migrations/{create_raclette_tables.rb.erb → create_pecorino_tables.rb.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a58274f909ba72f93ce478129cd8cfb08893be9a6691a7a892b5e3be455fdd59
|
4
|
+
data.tar.gz: 9bd363bc28d2095a3394abc36f0291c21b7b10e8652b8238243167a262f44740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9fbe0ec9ca780eb2e546b0f47bfcb0b4c579ac2f688dc59b7ebbcad39ebba875759fe62982c80b8f04e39553df6d1a64f7e8e9300d8f32b6d5f57c7c8a68405
|
7
|
+
data.tar.gz: c909b8bb23045ef42eca9346f8956744aeb2f97d5c5446f62f5b16c808b56d99abbc291e5a40d2de31fa2027b4ed789567d51af98e44a23b4c0c2062cf7a71cd
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.2
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Pecorino is a rate limiter based on the concept of leaky buckets. It uses your D
|
|
4
4
|
|
5
5
|
Pecorino is designed to integrate seamlessly into any Rails application using a Postgres database (at the moment there is no MySQL support, we would be delighted if you could add it).
|
6
6
|
|
7
|
+
If you would like to know more about the leaky bucket algorithm: the [Wikipedia article](https://en.wikipedia.org/wiki/Leaky_bucket) is a great starting point.
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -58,7 +60,7 @@ Sometimes you don't want to use a throttle, but you want to track the amount add
|
|
58
60
|
|
59
61
|
|
60
62
|
```ruby
|
61
|
-
b = Pecorino::LeakyBucket.new(key: "some_b", capacity: 100, leak_rate:
|
63
|
+
b = Pecorino::LeakyBucket.new(key: "some_b", capacity: 100, leak_rate: 1)
|
62
64
|
b.fillup(2) #=> Pecorino::LeakyBucket::State(full?: false, level: 2.0)
|
63
65
|
sleep 0.2
|
64
66
|
b.state #=> Pecorino::LeakyBucket::State(full?: false, level: 1.8)
|
@@ -72,15 +74,24 @@ We recommend running the following bit of code every couple of hours (via cron o
|
|
72
74
|
|
73
75
|
Pecorino.prune!
|
74
76
|
|
77
|
+
## Using unlogged tables for reduced replication load
|
78
|
+
|
79
|
+
Throttles and leaky buckets are transient resources. If you are using Postgres replication, it might be prudent to set the Pecorino tables to `UNLOGGED` which will exclude them from replication - and save you bandwidth and storage on your RR. To do so, add the following statements to your migration:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
ActiveRecord::Base.connection.execute("ALTER TABLE pecorino_leaky_buckets SET UNLOGGED")
|
83
|
+
ActiveRecord::Base.connection.execute("ALTER TABLE pecorino_blocks SET UNLOGGED")
|
84
|
+
```
|
85
|
+
|
75
86
|
## Development
|
76
87
|
|
77
|
-
After checking out the repo, run `bundle
|
88
|
+
After checking out the repo, run `bundle`. Then, run `rake test` to run the tests.
|
78
89
|
|
79
90
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
80
91
|
|
81
92
|
## Contributing
|
82
93
|
|
83
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cheddar-me/pecorino. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/cheddar-me/pecorino/blob/main/CODE_OF_CONDUCT.md).
|
84
95
|
|
85
96
|
## License
|
86
97
|
|
@@ -88,4 +99,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
88
99
|
|
89
100
|
## Code of Conduct
|
90
101
|
|
91
|
-
Everyone interacting in the Pecorino project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
102
|
+
Everyone interacting in the Pecorino project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cheddar-me/pecorino/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/pecorino/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pecorino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -80,14 +80,13 @@ files:
|
|
80
80
|
- CHANGELOG.md
|
81
81
|
- CODE_OF_CONDUCT.md
|
82
82
|
- Gemfile
|
83
|
-
- Gemfile.lock
|
84
83
|
- LICENSE.txt
|
85
84
|
- README.md
|
86
85
|
- Rakefile
|
87
86
|
- lib/pecorino.rb
|
88
87
|
- lib/pecorino/install_generator.rb
|
89
88
|
- lib/pecorino/leaky_bucket.rb
|
90
|
-
- lib/pecorino/migrations/
|
89
|
+
- lib/pecorino/migrations/create_pecorino_tables.rb.erb
|
91
90
|
- lib/pecorino/railtie.rb
|
92
91
|
- lib/pecorino/throttle.rb
|
93
92
|
- lib/pecorino/version.rb
|
@@ -114,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
113
|
- !ruby/object:Gem::Version
|
115
114
|
version: '0'
|
116
115
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.4.10
|
118
117
|
signing_key:
|
119
118
|
specification_version: 4
|
120
119
|
summary: Database-based rate limiter using leaky buckets
|
data/Gemfile.lock
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pecorino (0.1.0)
|
5
|
-
activerecord (~> 7)
|
6
|
-
pg
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actioncable (7.0.4)
|
12
|
-
actionpack (= 7.0.4)
|
13
|
-
activesupport (= 7.0.4)
|
14
|
-
nio4r (~> 2.0)
|
15
|
-
websocket-driver (>= 0.6.1)
|
16
|
-
actionmailbox (7.0.4)
|
17
|
-
actionpack (= 7.0.4)
|
18
|
-
activejob (= 7.0.4)
|
19
|
-
activerecord (= 7.0.4)
|
20
|
-
activestorage (= 7.0.4)
|
21
|
-
activesupport (= 7.0.4)
|
22
|
-
mail (>= 2.7.1)
|
23
|
-
net-imap
|
24
|
-
net-pop
|
25
|
-
net-smtp
|
26
|
-
actionmailer (7.0.4)
|
27
|
-
actionpack (= 7.0.4)
|
28
|
-
actionview (= 7.0.4)
|
29
|
-
activejob (= 7.0.4)
|
30
|
-
activesupport (= 7.0.4)
|
31
|
-
mail (~> 2.5, >= 2.5.4)
|
32
|
-
net-imap
|
33
|
-
net-pop
|
34
|
-
net-smtp
|
35
|
-
rails-dom-testing (~> 2.0)
|
36
|
-
actionpack (7.0.4)
|
37
|
-
actionview (= 7.0.4)
|
38
|
-
activesupport (= 7.0.4)
|
39
|
-
rack (~> 2.0, >= 2.2.0)
|
40
|
-
rack-test (>= 0.6.3)
|
41
|
-
rails-dom-testing (~> 2.0)
|
42
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
43
|
-
actiontext (7.0.4)
|
44
|
-
actionpack (= 7.0.4)
|
45
|
-
activerecord (= 7.0.4)
|
46
|
-
activestorage (= 7.0.4)
|
47
|
-
activesupport (= 7.0.4)
|
48
|
-
globalid (>= 0.6.0)
|
49
|
-
nokogiri (>= 1.8.5)
|
50
|
-
actionview (7.0.4)
|
51
|
-
activesupport (= 7.0.4)
|
52
|
-
builder (~> 3.1)
|
53
|
-
erubi (~> 1.4)
|
54
|
-
rails-dom-testing (~> 2.0)
|
55
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
56
|
-
activejob (7.0.4)
|
57
|
-
activesupport (= 7.0.4)
|
58
|
-
globalid (>= 0.3.6)
|
59
|
-
activemodel (7.0.4)
|
60
|
-
activesupport (= 7.0.4)
|
61
|
-
activerecord (7.0.4)
|
62
|
-
activemodel (= 7.0.4)
|
63
|
-
activesupport (= 7.0.4)
|
64
|
-
activestorage (7.0.4)
|
65
|
-
actionpack (= 7.0.4)
|
66
|
-
activejob (= 7.0.4)
|
67
|
-
activerecord (= 7.0.4)
|
68
|
-
activesupport (= 7.0.4)
|
69
|
-
marcel (~> 1.0)
|
70
|
-
mini_mime (>= 1.1.0)
|
71
|
-
activesupport (7.0.4)
|
72
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
73
|
-
i18n (>= 1.6, < 2)
|
74
|
-
minitest (>= 5.1)
|
75
|
-
tzinfo (~> 2.0)
|
76
|
-
builder (3.2.4)
|
77
|
-
concurrent-ruby (1.1.10)
|
78
|
-
crass (1.0.6)
|
79
|
-
erubi (1.11.0)
|
80
|
-
globalid (1.0.0)
|
81
|
-
activesupport (>= 5.0)
|
82
|
-
i18n (1.12.0)
|
83
|
-
concurrent-ruby (~> 1.0)
|
84
|
-
loofah (2.19.0)
|
85
|
-
crass (~> 1.0.2)
|
86
|
-
nokogiri (>= 1.5.9)
|
87
|
-
mail (2.7.1)
|
88
|
-
mini_mime (>= 0.1.1)
|
89
|
-
marcel (1.0.2)
|
90
|
-
method_source (1.0.0)
|
91
|
-
mini_mime (1.1.2)
|
92
|
-
minitest (5.16.3)
|
93
|
-
net-imap (0.3.1)
|
94
|
-
net-protocol
|
95
|
-
net-pop (0.1.2)
|
96
|
-
net-protocol
|
97
|
-
net-protocol (0.1.3)
|
98
|
-
timeout
|
99
|
-
net-smtp (0.3.2)
|
100
|
-
net-protocol
|
101
|
-
nio4r (2.5.8)
|
102
|
-
nokogiri (1.13.8-x86_64-darwin)
|
103
|
-
racc (~> 1.4)
|
104
|
-
pg (1.3.2)
|
105
|
-
racc (1.6.0)
|
106
|
-
rack (2.2.4)
|
107
|
-
rack-test (2.0.2)
|
108
|
-
rack (>= 1.3)
|
109
|
-
rails (7.0.4)
|
110
|
-
actioncable (= 7.0.4)
|
111
|
-
actionmailbox (= 7.0.4)
|
112
|
-
actionmailer (= 7.0.4)
|
113
|
-
actionpack (= 7.0.4)
|
114
|
-
actiontext (= 7.0.4)
|
115
|
-
actionview (= 7.0.4)
|
116
|
-
activejob (= 7.0.4)
|
117
|
-
activemodel (= 7.0.4)
|
118
|
-
activerecord (= 7.0.4)
|
119
|
-
activestorage (= 7.0.4)
|
120
|
-
activesupport (= 7.0.4)
|
121
|
-
bundler (>= 1.15.0)
|
122
|
-
railties (= 7.0.4)
|
123
|
-
rails-dom-testing (2.0.3)
|
124
|
-
activesupport (>= 4.2.0)
|
125
|
-
nokogiri (>= 1.6)
|
126
|
-
rails-html-sanitizer (1.4.3)
|
127
|
-
loofah (~> 2.3)
|
128
|
-
railties (7.0.4)
|
129
|
-
actionpack (= 7.0.4)
|
130
|
-
activesupport (= 7.0.4)
|
131
|
-
method_source
|
132
|
-
rake (>= 12.2)
|
133
|
-
thor (~> 1.0)
|
134
|
-
zeitwerk (~> 2.5)
|
135
|
-
rake (13.0.6)
|
136
|
-
thor (1.2.1)
|
137
|
-
timeout (0.3.0)
|
138
|
-
tzinfo (2.0.5)
|
139
|
-
concurrent-ruby (~> 1.0)
|
140
|
-
websocket-driver (0.7.5)
|
141
|
-
websocket-extensions (>= 0.1.0)
|
142
|
-
websocket-extensions (0.1.5)
|
143
|
-
zeitwerk (2.6.1)
|
144
|
-
|
145
|
-
PLATFORMS
|
146
|
-
x86_64-darwin-19
|
147
|
-
|
148
|
-
DEPENDENCIES
|
149
|
-
activesupport (~> 7)
|
150
|
-
minitest (~> 5.0)
|
151
|
-
pecorino!
|
152
|
-
rails (~> 7)
|
153
|
-
rake (~> 13.0)
|
154
|
-
|
155
|
-
BUNDLED WITH
|
156
|
-
2.3.5
|
/data/lib/pecorino/migrations/{create_raclette_tables.rb.erb → create_pecorino_tables.rb.erb}
RENAMED
File without changes
|