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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c04c3679d1562422a91fc38c90006c891199ae292a2452656bcef8d5f7d2b56b
4
- data.tar.gz: 9b966859811d80f276405e1d2d7a2550ba978e23a433cf7bbef04b44520c1929
3
+ metadata.gz: 398a422d9e426d44f0e535293f8c86d5793943b36465c445a88eeb5023b41966
4
+ data.tar.gz: 9edf8daa24d823759dbf6c4ff972fc857b1e90c597e6f6de326d23440a0b3e7e
5
5
  SHA512:
6
- metadata.gz: 3db14933d35669507a9fa818a56909f4e52dd6256cf169e1c1f0ce8f7c442314bb323265f8e0c9dcc74ee4b3d367d358abedcc1b36e0924d71c91100ba62b539
7
- data.tar.gz: 5f495f30d22525a0068cb9b591769f469a61073829a23e1b9b9adf3ffb2e2ea498b854c05cca35cf51a3a1883f04186b86a5b3aca3d9ed698e4af79ecd80f08b
6
+ metadata.gz: e8b0e7f6a8eb03df0d5bc5a64411187fb54d3029e9fa8ec67ec3dfbef7296625429869605ebc20053ef7d687baa9a4346101a01a7f8f581949d81598796ce352
7
+ data.tar.gz: 7d68eb887d4388c9bbd6b6b961c7d94562e18d9e1bf85f853177b22baa1007bb6f16d54fcc13b69a53c893bb78a47f0ff6ea9c380587ab68833f9fb4788ca4c9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Falcon
7
7
  module Limiter
8
- VERSION = "0.4.0"
8
+ VERSION = "0.5.0"
9
9
  end
10
10
  end
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
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.5.0
4
+
5
+ - Add optional `Falcon::Limiter::LongTask#start(tags:)` metadata for instrumentation.
6
+
3
7
  ## v0.4.0
4
8
 
5
9
  - Add `Falcon::Limiter::LongTask#pending?` for detecting delayed long tasks which have not acquired yet.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon-limiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file