falcon-limiter 0.4.0 → 0.5.0
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
- checksums.yaml.gz.sig +0 -0
- data/context/long-tasks.md +10 -0
- data/lib/falcon/limiter/long_task.rb +8 -1
- data/lib/falcon/limiter/version.rb +1 -1
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 398a422d9e426d44f0e535293f8c86d5793943b36465c445a88eeb5023b41966
|
|
4
|
+
data.tar.gz: 9edf8daa24d823759dbf6c4ff972fc857b1e90c597e6f6de326d23440a0b3e7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8b0e7f6a8eb03df0d5bc5a64411187fb54d3029e9fa8ec67ec3dfbef7296625429869605ebc20053ef7d687baa9a4346101a01a7f8f581949d81598796ce352
|
|
7
|
+
data.tar.gz: 7d68eb887d4388c9bbd6b6b961c7d94562e18d9e1bf85f853177b22baa1007bb6f16d54fcc13b69a53c893bb78a47f0ff6ea9c380587ab68833f9fb4788ca4c9
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/long-tasks.md
CHANGED
|
@@ -128,6 +128,16 @@ end
|
|
|
128
128
|
|
|
129
129
|
The block form ensures the long task is properly stopped even if an exception occurs. They can also be nested.
|
|
130
130
|
|
|
131
|
+
### Tags
|
|
132
|
+
|
|
133
|
+
You can attach application-specific metadata when starting a long task:
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
Falcon::Limiter::LongTask.current.start(tags: {name: :external_api_call})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Tags are stored on the long task while it is started or pending, and cleared when it stops. The limiter does not interpret tags directly; they are intended for instrumentation layers.
|
|
140
|
+
|
|
131
141
|
## Long Task Lifecycle
|
|
132
142
|
|
|
133
143
|
### 1. Creation
|
|
@@ -19,6 +19,8 @@ module Falcon
|
|
|
19
19
|
# The priority to use when stopping a long task to re-acquire the connection token.
|
|
20
20
|
STOP_PRIORITY = 1000
|
|
21
21
|
|
|
22
|
+
attr_reader :tags
|
|
23
|
+
|
|
22
24
|
# @returns [LongTask] The current long task.
|
|
23
25
|
def self.current
|
|
24
26
|
Fiber.current.falcon_limiter_long_task
|
|
@@ -63,6 +65,7 @@ module Falcon
|
|
|
63
65
|
|
|
64
66
|
@token = Async::Limiter::Token.new(@limiter)
|
|
65
67
|
@delayed_start_task = nil
|
|
68
|
+
@tags = nil
|
|
66
69
|
end
|
|
67
70
|
|
|
68
71
|
# Check if the long task has been started, but not necessarily acquired (e.g. if there was a delay).
|
|
@@ -84,7 +87,7 @@ module Falcon
|
|
|
84
87
|
end
|
|
85
88
|
|
|
86
89
|
# Start the long task, optionally with a delay to avoid overhead for short operations
|
|
87
|
-
def start(delay: @start_delay)
|
|
90
|
+
def start(delay: @start_delay, tags: nil)
|
|
88
91
|
# If already started, nothing to do:
|
|
89
92
|
if started?
|
|
90
93
|
if block_given?
|
|
@@ -100,6 +103,8 @@ module Falcon
|
|
|
100
103
|
delay = nil
|
|
101
104
|
end
|
|
102
105
|
|
|
106
|
+
@tags = tags
|
|
107
|
+
|
|
103
108
|
# Otherwise, start the long task:
|
|
104
109
|
if delay&.positive?
|
|
105
110
|
# Wait specified delay before starting the long task:
|
|
@@ -137,6 +142,8 @@ module Falcon
|
|
|
137
142
|
|
|
138
143
|
# Release the long task token:
|
|
139
144
|
release(force, **options)
|
|
145
|
+
ensure
|
|
146
|
+
@tags = nil
|
|
140
147
|
end
|
|
141
148
|
|
|
142
149
|
private
|
data/readme.md
CHANGED
|
@@ -26,6 +26,10 @@ Please see the [project documentation](https://socketry.github.io/falcon-limiter
|
|
|
26
26
|
|
|
27
27
|
Please see the [project releases](https://socketry.github.io/falcon-limiter/releases/index) for all releases.
|
|
28
28
|
|
|
29
|
+
### v0.5.0
|
|
30
|
+
|
|
31
|
+
- Add optional `Falcon::Limiter::LongTask#start(tags:)` metadata for instrumentation.
|
|
32
|
+
|
|
29
33
|
### v0.4.0
|
|
30
34
|
|
|
31
35
|
- Add `Falcon::Limiter::LongTask#pending?` for detecting delayed long tasks which have not acquired yet.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|