maybe_later 0.0.1 → 0.0.2
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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -6
- data/lib/maybe_later/middleware.rb +4 -2
- data/lib/maybe_later/store.rb +0 -4
- data/lib/maybe_later/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f9b846afbd0afe731fb08fd0d8bb7803bbe35641e346a203ec3d7dbdec5469
|
4
|
+
data.tar.gz: 9e524137408d44ed6c8aa9ac42530988cc1effd900b30b6cb5d4105bab2aabc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f44f66474c11bde93b9708a2357aa353abd7d10ea395af1da2494cabb6b5e364b2b9234ff3a3dbb0e386935c5486e92a2ebfc03046fac2d7053f73669c535f2f
|
7
|
+
data.tar.gz: 8d643450ef22440c17d881c20be5620e9029318d5ce979217a0b6f1bf41483dc0ee36b1406d8add4ebdca21742dbce037c246d8ec8a7a46b6dd44b0210a25e50
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ MaybeLater.run {
|
|
50
50
|
```
|
51
51
|
|
52
52
|
Each block passed to `MaybeLater.run` will be run after the HTTP response is
|
53
|
-
sent
|
53
|
+
sent.
|
54
54
|
|
55
55
|
If the code you're calling needs to be executed in the same thread that's
|
56
56
|
handling the HTTP request, you can pass `inline: true`:
|
@@ -61,9 +61,15 @@ MaybeLater.run(inline: true) {
|
|
61
61
|
}
|
62
62
|
```
|
63
63
|
|
64
|
-
And your code will be run right after the HTTP response is sent
|
65
|
-
|
66
|
-
|
64
|
+
And your code will be run right after the HTTP response is sent. Additionally,
|
65
|
+
if there are any inline tasks to be run, the response will include a
|
66
|
+
`"Connection: close` header so that the browser doesn't sit waiting on its
|
67
|
+
connection while the web thread executes the deferred code.
|
68
|
+
|
69
|
+
_[**Warning about `inline`:** running
|
70
|
+
slow inline tasks runs the risk of saturating the server's available threads
|
71
|
+
listening for connections, effectively shifting the slowness of one request onto
|
72
|
+
later ones!]_
|
67
73
|
|
68
74
|
|
69
75
|
## Configuration
|
@@ -72,7 +78,7 @@ The gem offers a few configuration options:
|
|
72
78
|
|
73
79
|
```ruby
|
74
80
|
MaybeLater.config do |config|
|
75
|
-
# Will be called if a
|
81
|
+
# Will be called if a block passed to MaybeLater.run raises an error
|
76
82
|
config.on_error = ->(error) {
|
77
83
|
# e.g. Honeybadger.notify(error)
|
78
84
|
}
|
@@ -92,7 +98,7 @@ end
|
|
92
98
|
## Help! Why isn't my code running?
|
93
99
|
|
94
100
|
If the blocks you pass to `MaybeLater.run` aren't running, possible
|
95
|
-
explanations:
|
101
|
+
explanations include:
|
96
102
|
|
97
103
|
* Because the blocks passed to `MaybeLater.run` are themselves stored in a
|
98
104
|
thread-local array, if you invoke `MaybeLater.run` from a thread that isn't
|
@@ -8,12 +8,14 @@ module MaybeLater
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
status, headers, body = @app.call(env)
|
11
|
-
if Store.instance.
|
11
|
+
if Store.instance.callbacks.any?
|
12
12
|
env[RACK_AFTER_REPLY] ||= []
|
13
13
|
env[RACK_AFTER_REPLY] << -> {
|
14
14
|
RunsCallbacks.new.call
|
15
15
|
}
|
16
|
-
|
16
|
+
if Store.instance.callbacks.any? { |cb| cb.inline }
|
17
|
+
headers["Connection"] = "close"
|
18
|
+
end
|
17
19
|
end
|
18
20
|
[status, headers, body]
|
19
21
|
end
|
data/lib/maybe_later/store.rb
CHANGED
data/lib/maybe_later/version.rb
CHANGED