maybe_later 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/maybe_later/config.rb +3 -1
- data/lib/maybe_later/middleware.rb +20 -3
- data/lib/maybe_later/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acd7c4af474d9ccd6ed38814145b1a4df0b2185ff13359f9ab04d0f2761e0aa2
|
4
|
+
data.tar.gz: 8fa43fe122c043094904189724798d3def150b5ca1469912662f037de0ba2dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbefe63d4710db4b36aa4b628e25e0a977922675695a3c9501c5ecc9d8ab9f851906f2ed53cc3d1e3c095c01e96bede99a7976c20d25ef2e4bf8e5dd5ceb8fe1
|
7
|
+
data.tar.gz: 176f10b2bd8aa8a7a6e5342d566a0df041ef33e4052b5f6333d75f4c61304892d4ac312d97127687c2b487250e4c84f946c8450360117c2e2847cd6987543582
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.0.4] - 2022-01-24
|
2
|
+
|
3
|
+
- Add `invoke_even_if_server_is_unsupported` option to ensure tasks are invoked
|
4
|
+
even if the server doesn't support rack.after_reply
|
5
|
+
|
1
6
|
## [0.0.3] - 2022-01-21
|
2
7
|
|
3
8
|
- Fix a bug where async tasks' after_each callbacks were called rack.after_reply
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -94,6 +94,10 @@ MaybeLater.config do |config|
|
|
94
94
|
|
95
95
|
# How many threads to allocate to the fixed thread pool (default: 5)
|
96
96
|
config.max_threads = 5
|
97
|
+
|
98
|
+
# If set to true, will invoke the after_reply tasks even if the server doesn't
|
99
|
+
# provide an array of rack.after_reply array
|
100
|
+
config.invoke_even_if_server_is_unsupported = false
|
97
101
|
end
|
98
102
|
```
|
99
103
|
|
data/lib/maybe_later/config.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module MaybeLater
|
2
2
|
class Config
|
3
|
-
attr_accessor :after_each, :on_error, :inline_by_default, :max_threads
|
3
|
+
attr_accessor :after_each, :on_error, :inline_by_default, :max_threads,
|
4
|
+
:invoke_even_if_server_is_unsupported
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@after_each = nil
|
7
8
|
@on_error = nil
|
8
9
|
@inline_by_default = false
|
9
10
|
@max_threads = 5
|
11
|
+
@invoke_even_if_server_is_unsupported = false
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -7,12 +7,29 @@ module MaybeLater
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
config = MaybeLater.config
|
11
|
+
|
10
12
|
status, headers, body = @app.call(env)
|
11
13
|
if Store.instance.callbacks.any?
|
12
|
-
env
|
13
|
-
|
14
|
+
if env.key?(RACK_AFTER_REPLY)
|
15
|
+
env[RACK_AFTER_REPLY] << -> {
|
16
|
+
RunsCallbacks.new.call
|
17
|
+
}
|
18
|
+
elsif !config.invoke_even_if_server_is_unsupported
|
19
|
+
warn <<~MSG
|
20
|
+
This server may not support '#{RACK_AFTER_REPLY}' callbacks. To
|
21
|
+
ensure that your tasks are executed, consider enabling:
|
22
|
+
|
23
|
+
config.invoke_even_if_server_is_unsupported = true
|
24
|
+
|
25
|
+
Note that this option, when combined with `inline: true` can result
|
26
|
+
in delayed flushing of HTTP responses by the server (defeating the
|
27
|
+
purpose of the gem.
|
28
|
+
MSG
|
29
|
+
else
|
14
30
|
RunsCallbacks.new.call
|
15
|
-
|
31
|
+
end
|
32
|
+
|
16
33
|
if Store.instance.callbacks.any? { |cb| cb.inline }
|
17
34
|
headers["Connection"] = "close"
|
18
35
|
end
|
data/lib/maybe_later/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maybe_later
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|