idempo 0.1.2 → 0.1.3

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: 8f5d862a9c8b731c1678447b00637cbeee39a0713503455f39c6bbbe1906090e
4
- data.tar.gz: e482c6af0896c61131373ce7446557bb2ce57be5f2efc120241ac814fc28de5c
3
+ metadata.gz: 057a7d3947de8a08ae62e9f7de2f2b05fae6607c1662aac78c7b12544050f41d
4
+ data.tar.gz: d0d8a84c2b208fd27b2301f975a3cf582d0c7b9e1b572d61574febf1f9f31cf4
5
5
  SHA512:
6
- metadata.gz: 9bdd48ca7387d456e52d7ea1813116761399d7586353f56885b6458361078b32ba0a93edcd160d874623ed9313bfc39be6a81cd2d70f32c4863b5dc60134cf4f
7
- data.tar.gz: 458308ac0a75adda6ed83d6b018670d709ff5e5908ed3d0845da2b57d78100f3c9d5a6b432463908378c16637ef6ae14e607c9e3d5edde196068b12c72272646
6
+ metadata.gz: bb98caf618c0c0c8987de2bd3e9e3a277c0d23d72d7b24ae90c22a678e44675bfb5a23468d23d0b73e9ccc7ec8e90704df553852b72a346b4f28e00d7a441fcc
7
+ data.tar.gz: 4c66050b6e219abd0922bd9a3e72740344c78c65bf0d35af08e2f423f4f2b835da377662b785802a37db4806f996e565027f1e3bdceff9d5344d59fa03344930
data/README.md CHANGED
@@ -32,9 +32,23 @@ use Idempo, backend: Idempo::RedisBackend.new(Rails.application.config.redis_con
32
32
  and to initialize with a memory store as backend:
33
33
 
34
34
  ```ruby
35
- use Idempo, backend: Idempo::MemoryBackend.new)
35
+ use Idempo, backend: Idempo::MemoryBackend.new
36
36
  ```
37
37
 
38
+ In principle, the following requests qualify to be cached used the idempotency key:
39
+
40
+ * Any request which is not a `GET`, `HEAD` or `OPTIONS` and...
41
+ * Provides an `Idempotency-Key` or `X-Idempotency-Key` header
42
+
43
+ The default time for storing the cache is 30 seconds from the moment the request has finished generating. The response is going to be buffered, then serialized using msgpack, then deflated. Idempo will not cache the response if its size cannot be known in advance, and if the size of the response body exceeds a reasonable size (4 MB is our limit for the time being) - this is to prevent your storage from filling up with very large responses.
44
+
45
+ ## Controlling the behavior of Idempo
46
+
47
+ You can control the behavior of Idempo using special headers:
48
+
49
+ * Set `X-Idempo-Policy` to `no-store` to disable retention of the response even though it otherwise could be cached
50
+ * Set `X-Idempo-Persist-For-Seconds` to decimal number of seconds to store your response fo
51
+
38
52
  ## Development
39
53
 
40
54
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Idempo
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/idempo.rb CHANGED
@@ -141,6 +141,7 @@ class Idempo
141
141
  d = Digest::SHA256.new
142
142
  d << req.url << "\n"
143
143
  d << req.request_method << "\n"
144
+ d << req.get_header('HTTP_AUTHORIZATION').to_s << "\n"
144
145
  while chunk = req.env['rack.input'].read(1024 * 65)
145
146
  d << chunk
146
147
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idempo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-10-19 00:00:00.000000000 Z
12
+ date: 2021-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack