async-limiter 2.2.0 → 2.3.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: d153319af347142e9837f3a8e7523f47f2bbd28d56e497d03c0fd7279302af8f
4
- data.tar.gz: 9d1da2a75240ba77a68d26141abf50b677d5248b9bf191a50e8821aac3bceee7
3
+ metadata.gz: 20ea7fcd7cb0c04777113d99878872f59f2275d7df572555eb23e5176173103a
4
+ data.tar.gz: 65bd9ebbc338f9cb786adb711f01085b8e3fdade9ed5d8a5614a3710023a5863
5
5
  SHA512:
6
- metadata.gz: a35d89989f3d8faf3cd203a84b2e04125809ae07d6609ce0dc205214f97bc1bf11ab099bbc46542a3fa701674185e641461d548f67bb1d1325b8badce9b6c6cc
7
- data.tar.gz: df563bd337ae1e9157df61f0b47ae35d1e536b15ad5c0e7cb6fe7ebf48f32bf18249185307aa07d287c3c54df90f8463ce014531763536bd8f92428c0d13e0f9
6
+ metadata.gz: dbd5950c897046843d3cd9da278843aab29a46d5a4e6f2915dc971596353e97edeec4da100553f243eb31661243a51a05fbc3232758521fdf8840ddcddd7fd58
7
+ data.tar.gz: 4e1a47617c6239470ba15351d22f310d082062358159e7c9595f42a160ea87a694f9cd52a25daaaa19a6d42983c0869dd5580e31f97a7dcd3603de4e056d84cf
checksums.yaml.gz.sig CHANGED
Binary file
@@ -35,6 +35,9 @@ module Async
35
35
  @mutex = Mutex.new
36
36
  end
37
37
 
38
+ # @attribute [Timing] Strategy for timing constraints.
39
+ attr :timing
40
+
38
41
  # @attribute [Array(String)] Tags associated with this limiter for identification or categorization.
39
42
  attr :tags
40
43
 
@@ -14,7 +14,8 @@ module Async
14
14
  # re-acquisition with modified parameters while maintaining the original context.
15
15
  #
16
16
  # The token automatically tracks release state using the resource itself as the
17
- # state indicator (nil = released, non-nil = acquired).
17
+ # state indicator (nil = released, non-nil = acquired). A closed token also
18
+ # clears its limiter reference, which prevents future re-acquisition.
18
19
  class Token
19
20
  # Acquire a token from a limiter.
20
21
  #
@@ -61,6 +62,12 @@ module Async
61
62
  end
62
63
  end
63
64
 
65
+ # Close the token and prevent future re-acquisition.
66
+ def close
67
+ self.release
68
+ @limiter = nil
69
+ end
70
+
64
71
  # Re-acquire the resource with modified options.
65
72
  #
66
73
  # This allows changing acquisition parameters (timeout, cost, priority, etc.)
@@ -74,6 +81,7 @@ module Async
74
81
  # @asynchronous
75
82
  def acquire(**options, &block)
76
83
  raise "Token already acquired!" if @resource
84
+ return nil unless @limiter
77
85
 
78
86
  @resource = @limiter.acquire(reacquire: true, **options)
79
87
 
@@ -97,6 +105,12 @@ module Async
97
105
  def released?
98
106
  !@resource
99
107
  end
108
+
109
+ # Check if the token has been closed.
110
+ # @returns [Boolean] True if the token has been closed.
111
+ def closed?
112
+ !@limiter
113
+ end
100
114
  end
101
115
  end
102
116
  end
@@ -7,6 +7,6 @@
7
7
 
8
8
  module Async
9
9
  module Limiter
10
- VERSION = "2.2.0"
10
+ VERSION = "2.3.0"
11
11
  end
12
12
  end
data/readme.md CHANGED
@@ -24,6 +24,11 @@ Please see the [project documentation](https://socketry.github.io/async-limiter/
24
24
 
25
25
  Please see the [project releases](https://socketry.github.io/async-limiter/releases/index) for all releases.
26
26
 
27
+ ### v2.3.0
28
+
29
+ - Add `Async::Limiter::Token#close` to release and permanently invalidate a token.
30
+ - Expose `Async::Limiter::Generic#timing`.
31
+
27
32
  ### v2.2.0
28
33
 
29
34
  - Add `async-utilization` metrics for limiter telemetry counters.
data/releases.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Releases
2
2
 
3
+ ## v2.3.0
4
+
5
+ - Add `Async::Limiter::Token#close` to release and permanently invalidate a token.
6
+ - Expose `Async::Limiter::Generic#timing`.
7
+
3
8
  ## v2.2.0
4
9
 
5
10
  - Add `async-utilization` metrics for limiter telemetry counters.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-limiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Sutic
@@ -100,7 +100,7 @@ files:
100
100
  - license.md
101
101
  - readme.md
102
102
  - releases.md
103
- homepage: https://github.com/bruno-/async-limiter
103
+ homepage: https://github.com/socketry/async-limiter
104
104
  licenses:
105
105
  - MIT
106
106
  metadata:
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 4.0.6
123
+ rubygems_version: 4.0.3
124
124
  specification_version: 4
125
125
  summary: Execution rate limiting for Async
126
126
  test_files: []
metadata.gz.sig CHANGED
Binary file