async-pool 0.8.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/pool/controller.rb +42 -21
- data/lib/async/pool/resource.rb +3 -3
- data/lib/async/pool/version.rb +1 -1
- data/lib/async/pool.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +2 -16
- 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: ac992b5e13d56d0441655030e1ac893d10ceda32d022b38daf45e12539b8199e
|
4
|
+
data.tar.gz: 14d3a0585ad5d89f6b5016858b8fba5096bb71a703f9fafa1fcfe927ccad3355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ca9ce26be39afc0986243da26a97432ebc1761ba71e9f4ac2de8e7a9fdad161600276430a52737ddac43226c012c465c471c74442c4f5e146a4b20d530a5b1
|
7
|
+
data.tar.gz: bd9e8f5f3a90c08ae3faadfcd5d7ef1db9063d57b25e8ed2f981ccdba31968cfffdc98e1456fa01b5f42f1d112d1db560d69896fd7e9319225ac916aa8787422
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -5,14 +5,13 @@
|
|
5
5
|
# Copyright, 2020, by Simon Perepelitsa.
|
6
6
|
# Copyright, 2024, by Thomas Morgan.
|
7
7
|
|
8
|
-
require
|
8
|
+
require "console/logger"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
10
|
+
require "async"
|
11
|
+
require "async/notification"
|
12
|
+
require "async/semaphore"
|
13
13
|
|
14
|
-
require
|
15
|
-
require 'metrics'
|
14
|
+
require "traces"
|
16
15
|
|
17
16
|
module Async
|
18
17
|
module Pool
|
@@ -29,7 +28,7 @@ module Async
|
|
29
28
|
# @parameter limit [Integer | Nil] The maximum number of resources that this pool can have at any given time. If nil, the pool can have an unlimited number of resources.
|
30
29
|
# @parameter concurrency [Integer] The maximum number of concurrent tasks that can be creating a new resource.
|
31
30
|
# @parameter policy [Policy] The pool policy.
|
32
|
-
def initialize(constructor, limit: nil, concurrency: (limit || 1), policy: nil)
|
31
|
+
def initialize(constructor, limit: nil, concurrency: (limit || 1), policy: nil, tags: nil)
|
33
32
|
@constructor = constructor
|
34
33
|
@limit = limit
|
35
34
|
|
@@ -39,6 +38,8 @@ module Async
|
|
39
38
|
@policy = policy
|
40
39
|
@gardener = nil
|
41
40
|
|
41
|
+
@tags = tags
|
42
|
+
|
42
43
|
# All available resources:
|
43
44
|
@resources = {}
|
44
45
|
|
@@ -96,6 +97,9 @@ module Async
|
|
96
97
|
# @attribute [Hash(Resource, Integer)] all allocated resources, and their associated usage.
|
97
98
|
attr :resources
|
98
99
|
|
100
|
+
# @attribute [Array(String)] The name of the pool.
|
101
|
+
attr_accessor :tags
|
102
|
+
|
99
103
|
# The number of resources in the pool.
|
100
104
|
def size
|
101
105
|
@resources.size
|
@@ -390,6 +394,8 @@ module Async
|
|
390
394
|
limit: @limit,
|
391
395
|
}
|
392
396
|
|
397
|
+
@attributes.merge!(@tags) if @tags
|
398
|
+
|
393
399
|
Traces.trace('async.pool.create', attributes: attributes) {super}
|
394
400
|
end
|
395
401
|
|
@@ -398,31 +404,46 @@ module Async
|
|
398
404
|
size: @resources.size,
|
399
405
|
}
|
400
406
|
|
407
|
+
@attributes.merge!(@tags) if @tags
|
408
|
+
|
401
409
|
Traces.trace('async.pool.drain', attributes: attributes) {super}
|
402
410
|
end
|
403
|
-
end
|
404
|
-
|
405
|
-
Metrics::Provider(self) do
|
406
|
-
ACQUIRE_COUNT = Metrics.metric('async.pool.acquire', :counter, description: 'Number of times a resource was invoked.')
|
407
|
-
RELEASE_COUNT = Metrics.metric('async.pool.release', :counter, description: 'Number of times a resource was released.')
|
408
|
-
RETIRE_COUNT = Metrics.metric('async.pool.retire', :counter, description: 'Number of times a resource was retired.')
|
409
411
|
|
410
412
|
def acquire(...)
|
411
|
-
|
413
|
+
attributes = {
|
414
|
+
concurrency: @guard.limit,
|
415
|
+
size: @resources.size,
|
416
|
+
limit: @limit,
|
417
|
+
}
|
412
418
|
|
413
|
-
|
419
|
+
@attributes.merge!(@tags) if @tags
|
420
|
+
|
421
|
+
Traces.trace('async.pool.acquire', attributes: attributes) {super}
|
414
422
|
end
|
415
423
|
|
416
424
|
def release(...)
|
417
|
-
|
418
|
-
|
419
|
-
|
425
|
+
attributes = {
|
426
|
+
concurrency: @guard.limit,
|
427
|
+
size: @resources.size,
|
428
|
+
limit: @limit,
|
429
|
+
}
|
430
|
+
|
431
|
+
@attributes.merge!(@tags) if @tags
|
432
|
+
|
433
|
+
Traces.trace('async.pool.release', attributes: attributes) {super}
|
420
434
|
end
|
421
435
|
|
422
436
|
def retire(...)
|
423
|
-
|
424
|
-
|
425
|
-
|
437
|
+
attributes = {
|
438
|
+
concurrency: @guard.limit,
|
439
|
+
size: @resources.size,
|
440
|
+
limit: @limit,
|
441
|
+
**@tags,
|
442
|
+
}
|
443
|
+
|
444
|
+
@attributes.merge!(@tags) if @tags
|
445
|
+
|
446
|
+
Traces.trace('async.pool.retire', attributes: attributes) {super}
|
426
447
|
end
|
427
448
|
end
|
428
449
|
end
|
data/lib/async/pool/resource.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "console/logger"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "async/notification"
|
9
|
+
require "async/semaphore"
|
10
10
|
|
11
11
|
module Async
|
12
12
|
module Pool
|
data/lib/async/pool/version.rb
CHANGED
data/lib/async/pool.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2024-
|
43
|
+
date: 2024-10-13 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async
|
@@ -56,20 +56,6 @@ dependencies:
|
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '1.25'
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
|
-
name: metrics
|
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
59
|
- !ruby/object:Gem::Dependency
|
74
60
|
name: traces
|
75
61
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|