async-pool 0.10.2 → 0.11.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/lib/async/pool/controller.rb +28 -68
- data/lib/async/pool/version.rb +2 -2
- data/lib/traces/provider/async/pool/controller.rb +59 -0
- data/license.md +2 -1
- data/readme.md +6 -0
- data/releases.md +3 -0
- data.tar.gz.sig +0 -0
- metadata +9 -25
- 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: fced21c28680f832d46cd11769b97d5a1dfd7a46761c58a144a1ff5ce178c7ff
|
4
|
+
data.tar.gz: e23c00cb8b7d48be97f5df59b6f05ea3728b40edbca97cda347740140d77621c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a14bbfcb0c1dcd18f044de7caaf901c3ac17d80431342c0e584bd97d311d7d0acb12ec7004f5c0cf4942d406b90a2536ab9bb1297c393b03e3129572b082d342
|
7
|
+
data.tar.gz: b36b8d19bde4f2503781f828b2a8df3d871915dc852c942658c6779ffa51a0b7e4d29daab077e73a8967f9a2d3734df5437dd433d94aa8c7b9a9a38c4ef4d708
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
5
5
|
# Copyright, 2020, by Simon Perepelitsa.
|
6
6
|
# Copyright, 2024, by Thomas Morgan.
|
7
|
+
# Copyright, 2025, by Jean Boussier.
|
7
8
|
|
8
9
|
require "console/logger"
|
9
10
|
|
10
11
|
require "async"
|
11
|
-
require "async/notification"
|
12
12
|
require "async/semaphore"
|
13
13
|
|
14
|
-
require "
|
14
|
+
require "thread"
|
15
15
|
|
16
16
|
module Async
|
17
17
|
module Pool
|
@@ -48,7 +48,8 @@ module Async
|
|
48
48
|
@available = []
|
49
49
|
|
50
50
|
# Used to signal when a resource has been released:
|
51
|
-
@
|
51
|
+
@mutex = Thread::Mutex.new
|
52
|
+
@condition = Thread::ConditionVariable.new
|
52
53
|
end
|
53
54
|
|
54
55
|
# @attribute [Proc] The constructor used to create new resources.
|
@@ -125,8 +126,23 @@ module Async
|
|
125
126
|
end
|
126
127
|
|
127
128
|
# Wait until a pool resource has been freed.
|
129
|
+
# @deprecated Use {wait_until_free} instead.
|
128
130
|
def wait
|
129
|
-
@
|
131
|
+
@mutex.synchronize do
|
132
|
+
@condition.wait(@mutex)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Wait until the pool is not busy (no resources in use).
|
137
|
+
def wait_until_free
|
138
|
+
@mutex.synchronize do
|
139
|
+
if busy?
|
140
|
+
yield self if block_given?
|
141
|
+
|
142
|
+
# Wait until the pool is not busy:
|
143
|
+
@condition.wait(@mutex) while busy?
|
144
|
+
end
|
145
|
+
end
|
130
146
|
end
|
131
147
|
|
132
148
|
# Whether the pool is empty.
|
@@ -161,6 +177,7 @@ module Async
|
|
161
177
|
retire(resource) unless processed
|
162
178
|
end
|
163
179
|
|
180
|
+
# Drain the pool, closing all resources.
|
164
181
|
def drain
|
165
182
|
Console.debug(self, "Draining pool...", size: @resources.size)
|
166
183
|
|
@@ -170,7 +187,7 @@ module Async
|
|
170
187
|
end
|
171
188
|
end
|
172
189
|
|
173
|
-
#
|
190
|
+
# Drain the pool, clear all resources, and stop the gardener.
|
174
191
|
def close
|
175
192
|
self.drain
|
176
193
|
|
@@ -221,7 +238,7 @@ module Async
|
|
221
238
|
|
222
239
|
resource.close
|
223
240
|
|
224
|
-
@
|
241
|
+
@mutex.synchronize {@condition.broadcast}
|
225
242
|
|
226
243
|
return true
|
227
244
|
end
|
@@ -285,7 +302,7 @@ module Async
|
|
285
302
|
|
286
303
|
@resources[resource] = usage - 1
|
287
304
|
|
288
|
-
@
|
305
|
+
@mutex.synchronize {@condition.broadcast}
|
289
306
|
|
290
307
|
return true
|
291
308
|
end
|
@@ -293,11 +310,9 @@ module Async
|
|
293
310
|
def wait_for_resource
|
294
311
|
# If we fail to create a resource (below), we will end up waiting for one to become resources.
|
295
312
|
until resource = available_resource
|
296
|
-
@
|
313
|
+
@mutex.synchronize {@condition.wait(@mutex)}
|
297
314
|
end
|
298
|
-
|
299
315
|
# Be careful not to context switch or fail here.
|
300
|
-
|
301
316
|
return resource
|
302
317
|
end
|
303
318
|
|
@@ -329,7 +344,7 @@ module Async
|
|
329
344
|
end
|
330
345
|
|
331
346
|
return resource
|
332
|
-
rescue Exception
|
347
|
+
rescue Exception
|
333
348
|
reuse(resource) if resource
|
334
349
|
raise
|
335
350
|
end
|
@@ -345,10 +360,8 @@ module Async
|
|
345
360
|
return resource
|
346
361
|
end
|
347
362
|
end
|
348
|
-
|
349
|
-
@notification.wait
|
363
|
+
@mutex.synchronize {@condition.wait(@mutex)}
|
350
364
|
end
|
351
|
-
|
352
365
|
# Only when the pool has been completely drained, return nil:
|
353
366
|
return nil
|
354
367
|
end
|
@@ -381,59 +394,6 @@ module Async
|
|
381
394
|
return create_resource
|
382
395
|
end
|
383
396
|
end
|
384
|
-
|
385
|
-
Traces::Provider(self) do
|
386
|
-
def create_resource(...)
|
387
|
-
attributes = {
|
388
|
-
concurrency: @guard.limit,
|
389
|
-
}
|
390
|
-
|
391
|
-
attributes.merge!(@tags) if @tags
|
392
|
-
|
393
|
-
Traces.trace('async.pool.create', attributes: attributes) {super}
|
394
|
-
end
|
395
|
-
|
396
|
-
def drain(...)
|
397
|
-
attributes = {
|
398
|
-
size: @resources.size,
|
399
|
-
}
|
400
|
-
|
401
|
-
attributes.merge!(@tags) if @tags
|
402
|
-
|
403
|
-
Traces.trace('async.pool.drain', attributes: attributes) {super}
|
404
|
-
end
|
405
|
-
|
406
|
-
def acquire(...)
|
407
|
-
attributes = {
|
408
|
-
size: @resources.size,
|
409
|
-
limit: @limit,
|
410
|
-
}
|
411
|
-
|
412
|
-
attributes.merge!(@tags) if @tags
|
413
|
-
|
414
|
-
Traces.trace('async.pool.acquire', attributes: attributes) {super}
|
415
|
-
end
|
416
|
-
|
417
|
-
def release(...)
|
418
|
-
attributes = {
|
419
|
-
size: @resources.size,
|
420
|
-
}
|
421
|
-
|
422
|
-
attributes.merge!(@tags) if @tags
|
423
|
-
|
424
|
-
Traces.trace('async.pool.release', attributes: attributes) {super}
|
425
|
-
end
|
426
|
-
|
427
|
-
def retire(...)
|
428
|
-
attributes = {
|
429
|
-
size: @resources.size,
|
430
|
-
}
|
431
|
-
|
432
|
-
attributes.merge!(@tags) if @tags
|
433
|
-
|
434
|
-
Traces.trace('async.pool.retire', attributes: attributes) {super}
|
435
|
-
end
|
436
|
-
end
|
437
397
|
end
|
438
398
|
end
|
439
399
|
end
|
data/lib/async/pool/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2025, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative "../../../../async/pool/controller"
|
7
|
+
|
8
|
+
Traces::Provider(Async::Pool::Controller) do
|
9
|
+
def create_resource(...)
|
10
|
+
attributes = {
|
11
|
+
concurrency: @guard.limit,
|
12
|
+
}
|
13
|
+
|
14
|
+
attributes.merge!(@tags) if @tags
|
15
|
+
|
16
|
+
Traces.trace("async.pool.create", attributes: attributes) {super}
|
17
|
+
end
|
18
|
+
|
19
|
+
def drain(...)
|
20
|
+
attributes = {
|
21
|
+
size: @resources.size,
|
22
|
+
}
|
23
|
+
|
24
|
+
attributes.merge!(@tags) if @tags
|
25
|
+
|
26
|
+
Traces.trace("async.pool.drain", attributes: attributes) {super}
|
27
|
+
end
|
28
|
+
|
29
|
+
def acquire(...)
|
30
|
+
attributes = {
|
31
|
+
size: @resources.size,
|
32
|
+
limit: @limit,
|
33
|
+
}
|
34
|
+
|
35
|
+
attributes.merge!(@tags) if @tags
|
36
|
+
|
37
|
+
Traces.trace("async.pool.acquire", attributes: attributes) {super}
|
38
|
+
end
|
39
|
+
|
40
|
+
def release(...)
|
41
|
+
attributes = {
|
42
|
+
size: @resources.size,
|
43
|
+
}
|
44
|
+
|
45
|
+
attributes.merge!(@tags) if @tags
|
46
|
+
|
47
|
+
Traces.trace("async.pool.release", attributes: attributes) {super}
|
48
|
+
end
|
49
|
+
|
50
|
+
def retire(...)
|
51
|
+
attributes = {
|
52
|
+
size: @resources.size,
|
53
|
+
}
|
54
|
+
|
55
|
+
attributes.merge!(@tags) if @tags
|
56
|
+
|
57
|
+
Traces.trace("async.pool.retire", attributes: attributes) {super}
|
58
|
+
end
|
59
|
+
end
|
data/license.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright, 2019-
|
3
|
+
Copyright, 2019-2025, by Samuel Williams.
|
4
4
|
Copyright, 2020, by Simon Perepelitsa.
|
5
5
|
Copyright, 2021, by Olle Jonsson.
|
6
6
|
Copyright, 2024, by Thomas Morgan.
|
7
|
+
Copyright, 2025, by Jean Boussier.
|
7
8
|
|
8
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
10
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -10,6 +10,12 @@ Please see the [project documentation](https://socketry.github.io/async-pool/) f
|
|
10
10
|
|
11
11
|
- [Getting Started](https://socketry.github.io/async-pool/guides/getting-started/index) - This guide explains how to use the `async-pool` gem to manage connection pooling.
|
12
12
|
|
13
|
+
## Releases
|
14
|
+
|
15
|
+
Please see the [project releases](https://socketry.github.io/async-pool/releases/index) for all releases.
|
16
|
+
|
17
|
+
### v0.11.0
|
18
|
+
|
13
19
|
## Contributing
|
14
20
|
|
15
21
|
We welcome contributions to this project.
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Jean Boussier
|
8
9
|
- Olle Jonsson
|
9
10
|
- Simon Perepelitsa
|
10
11
|
- Thomas Morgan
|
11
|
-
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain:
|
14
14
|
- |
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date:
|
43
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async
|
@@ -48,30 +48,14 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '2.0'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: traces
|
61
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
-
requirements:
|
63
|
-
- - ">="
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: !ruby/object:Gem::Requirement
|
69
|
-
requirements:
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '0'
|
73
|
-
description:
|
74
|
-
email:
|
58
|
+
version: '2.0'
|
75
59
|
executables: []
|
76
60
|
extensions: []
|
77
61
|
extra_rdoc_files: []
|
@@ -80,8 +64,10 @@ files:
|
|
80
64
|
- lib/async/pool/controller.rb
|
81
65
|
- lib/async/pool/resource.rb
|
82
66
|
- lib/async/pool/version.rb
|
67
|
+
- lib/traces/provider/async/pool/controller.rb
|
83
68
|
- license.md
|
84
69
|
- readme.md
|
70
|
+
- releases.md
|
85
71
|
homepage: https://github.com/socketry/async-pool
|
86
72
|
licenses:
|
87
73
|
- MIT
|
@@ -89,7 +75,6 @@ metadata:
|
|
89
75
|
documentation_uri: https://socketry.github.io/async-pool/
|
90
76
|
funding_uri: https://github.com/sponsors/ioquatix/
|
91
77
|
source_code_uri: https://github.com/socketry/async-pool.git
|
92
|
-
post_install_message:
|
93
78
|
rdoc_options: []
|
94
79
|
require_paths:
|
95
80
|
- lib
|
@@ -97,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
82
|
requirements:
|
98
83
|
- - ">="
|
99
84
|
- !ruby/object:Gem::Version
|
100
|
-
version: '3.
|
85
|
+
version: '3.2'
|
101
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
87
|
requirements:
|
103
88
|
- - ">="
|
104
89
|
- !ruby/object:Gem::Version
|
105
90
|
version: '0'
|
106
91
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
108
|
-
signing_key:
|
92
|
+
rubygems_version: 3.6.7
|
109
93
|
specification_version: 4
|
110
94
|
summary: A singleplex and multiplex resource pool for implementing robust clients.
|
111
95
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|