idempotent-request 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubygems.yml +35 -0
- data/.github/workflows/tests.yml +27 -0
- data/README.md +10 -3
- data/lib/idempotent-request/redis_storage.rb +4 -8
- data/lib/version.rb +1 -1
- metadata +5 -4
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b0c53b23f5b7ab67c2fc7e40db5b3a734df82620c02c7e35c3723db322164c2
|
4
|
+
data.tar.gz: 510cd8fbb82a67de98ddf2a103b3c3bb6c0c438e6efab76070f4ef45d9a9378d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a19a9267d4434c171977a8c93bd693f4639d3113ba81b749ac76f71d5544bfc6b52409055eca3a5cd73952fdecc53e673184f2bca6c449846fe83f7b15033d2
|
7
|
+
data.tar.gz: 62dc68accf7f1eaf68f6edb37eb5323c05a5ece9ef95e2073fe1ea8fe9bcace9b3e9689fccbbeda3db08ef0b751f9578b38eaf6a8044917e6baff0fd080e86f4
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths:
|
8
|
+
- lib/version.rb
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
name: Build and publish
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
environment: master
|
15
|
+
permissions:
|
16
|
+
contents: read
|
17
|
+
packages: write
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v3
|
21
|
+
- name: Set up Ruby 3.2
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: 3.2.2
|
25
|
+
|
26
|
+
- name: Publish to RubyGems
|
27
|
+
run: |
|
28
|
+
mkdir -p $HOME/.gem
|
29
|
+
touch $HOME/.gem/credentials
|
30
|
+
chmod 0600 $HOME/.gem/credentials
|
31
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
32
|
+
gem build *.gemspec
|
33
|
+
gem push *.gem
|
34
|
+
env:
|
35
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: ["master"]
|
6
|
+
pull_request:
|
7
|
+
branches: ["master"]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v3
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
25
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
![Gem Version](https://badge.fury.io/rb/idempotent-request.svg) ![CI Status](https://github.com/qonto/idempotent-request/actions/workflows/tests.yml/badge.svg)
|
2
|
+
|
3
|
+
# Idempotent Requestidempotent-request
|
2
4
|
|
3
5
|
Rack middleware ensuring at most once requests for mutating endpoints.
|
4
6
|
|
@@ -140,11 +142,11 @@ Get notified when a client sends a request with the same idempotency key:
|
|
140
142
|
```ruby
|
141
143
|
class RailsCallback
|
142
144
|
attr_reader :request
|
143
|
-
|
145
|
+
|
144
146
|
def initialize(request)
|
145
147
|
@request = request
|
146
148
|
end
|
147
|
-
|
149
|
+
|
148
150
|
def detected(key:)
|
149
151
|
Rails.logger.warn "IdempotentRequest request detected, key: #{key}"
|
150
152
|
end
|
@@ -166,3 +168,8 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
166
168
|
## Code of Conduct
|
167
169
|
|
168
170
|
Everyone interacting in the Idempotent::Request project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/idempotent-request/blob/master/CODE_OF_CONDUCT.md).
|
171
|
+
|
172
|
+
|
173
|
+
## Releasing
|
174
|
+
|
175
|
+
To publish a new version to rubygems, update the version in `lib/version.rb`, and merge.
|
@@ -27,14 +27,10 @@ module IdempotentRequest
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def setnx_with_expiration(key, data)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
options[:nx] = true
|
35
|
-
options[:ex] = expire_time.to_i if expire_time.to_i > 0
|
36
|
-
end
|
37
|
-
)
|
30
|
+
options = {nx: true}
|
31
|
+
options[:ex] = expire_time.to_i if expire_time.to_i > 0
|
32
|
+
|
33
|
+
redis.set(key, data, **options)
|
38
34
|
end
|
39
35
|
|
40
36
|
def lock_key(key)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idempotent-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Zakharov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -115,9 +115,10 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- ".github/workflows/rubygems.yml"
|
119
|
+
- ".github/workflows/tests.yml"
|
118
120
|
- ".gitignore"
|
119
121
|
- ".rspec"
|
120
|
-
- ".travis.yml"
|
121
122
|
- CHANGELOG.md
|
122
123
|
- CODE_OF_CONDUCT.md
|
123
124
|
- Gemfile
|
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
153
|
- !ruby/object:Gem::Version
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.4.10
|
156
157
|
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Rack middleware ensuring at most once requests for mutating endpoints.
|
data/.travis.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.4.10
|
5
|
-
- 2.5.8
|
6
|
-
- 2.6.6
|
7
|
-
- 2.7.1
|
8
|
-
deploy:
|
9
|
-
skip_cleanup: true
|
10
|
-
provider: rubygems
|
11
|
-
api_key:
|
12
|
-
secure: JOZUQM6qAYJN/N0k4UmV3jBSKMaW3oMYiZ4boPrGm7MsUY8ETHXSYR+dDhrWOvDR4Wdr6DVbTmMtXkWJHaQaM/LkrjN2FM6mTuDfmhkcvi9VBOMstptwXeHMS9fWeogtQwHyd+pKac9vUlaMhRYyoeYyJ1i6/LHua4NftZZ8oPu/9kMuKDD3Rj8zPJNui+fGcZxq90XdxjafCfRJu7EnzSZXzVi5msaEBKcUVxsHxprBjyjmp/yh/Wn0GLyBkYYXkKEUNx9DhxVtWaNG2FfOzznj3HLXQgBdz1or1tDxG8iIegC5jEj4G+gLtldLhMYWfHDaEr4iqKLF1LkjO9TK0RjcVzGNHNxCTQaDDcjgimcVNozWg707IzT5Ap6jG4Y9JWk5KY4ysOaVFqhemafoDwQcXkPb+39N/tpeBPCByCVNrZ+5lgWaHvs+iDv0X9PyAFs5nTz6/u6bz7GDZ91oJOGs9OW6szzHwkQn5TN4omdGiOFca7lviz6OyjXeSn+a6whU2DsRXxp+omrPT/gELLGl21Wd3GGTpiGAdnu/vwvoKOZqGfkr8HS/Bozc0S/vafFJ5KoPAkNQ9iwxPgL1xcEbSF5uK67T2EYVKg7z4psXDeWGBWzk8657SBCB1VCgujkmhg+lWt0TGgrckupKSyUXL4/nnAECgizSLJSbgRE=
|
13
|
-
gem: idempotent-request
|
14
|
-
on:
|
15
|
-
tags: true
|
16
|
-
repo: qonto/idempotent-request
|