async-pool 0.8.1 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d877fb908af8482011de394630982c4c593e36a5efd9ef19a885bba5774f6e8
4
- data.tar.gz: be2d7efd8c65a9eec5237acc4f432e76a3f401da0b13e7e10b089f9849382f2a
3
+ metadata.gz: 003c7bc5ebfd789e4350f68af08301a24628b8782d1e9255ea69e6a92c74198a
4
+ data.tar.gz: 064e1ab27d50b280718157bf8bef400ca0c0850bed547983ae945b78b59c159d
5
5
  SHA512:
6
- metadata.gz: 3e472af40018c10b2a8d726fc31b04ea96557d790c55e4fe6449a891b048c96da66794926eb7ca726195f778d0bea1e6c9d762b274a06a0922f382d5a8794ab7
7
- data.tar.gz: 8abacfdcb4b32eb573e0108aecdbdd7ff385386e8a8de2710550b976a81467286e73fa8f36292162e801d5f000fc2a222aabf99f7cf334a35d7e22e47833ded1
6
+ metadata.gz: 19ea0dc13e3a20bff67f5f3948187e6dc088acef4fb18a3d57a6c8f7c9d24bd4cf9dbd81128f59c818a9e55b216904e512b99c85667a024d24b7f070831342b8
7
+ data.tar.gz: e39da4c0bc5c38cb7c5a1887976b08a5b0ec4c28195285e4a47b82d609f126326dbf2b3b5267c62dbe3615fd27c4f0a9afc7e07784840173bcde3ad3e652c20f
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 'console/logger'
8
+ require "console/logger"
9
9
 
10
- require 'async'
11
- require 'async/notification'
12
- require 'async/semaphore'
10
+ require "async"
11
+ require "async/notification"
12
+ require "async/semaphore"
13
13
 
14
- require 'traces'
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
@@ -386,10 +390,10 @@ module Async
386
390
  def create_resource(...)
387
391
  attributes = {
388
392
  concurrency: @guard.limit,
389
- size: @resources.size,
390
- limit: @limit,
391
393
  }
392
394
 
395
+ attributes.merge!(@tags) if @tags
396
+
393
397
  Traces.trace('async.pool.create', attributes: attributes) {super}
394
398
  end
395
399
 
@@ -398,31 +402,40 @@ module Async
398
402
  size: @resources.size,
399
403
  }
400
404
 
405
+ attributes.merge!(@tags) if @tags
406
+
401
407
  Traces.trace('async.pool.drain', attributes: attributes) {super}
402
408
  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
409
 
410
410
  def acquire(...)
411
- ACQUIRE_COUNT.emit(1)
411
+ attributes = {
412
+ size: @resources.size,
413
+ limit: @limit,
414
+ }
415
+
416
+ attributes.merge!(@tags) if @tags
412
417
 
413
- super
418
+ Traces.trace('async.pool.acquire', attributes: attributes) {super}
414
419
  end
415
420
 
416
421
  def release(...)
417
- super.tap do
418
- RELEASE_COUNT.emit(1)
419
- end
422
+ attributes = {
423
+ size: @resources.size,
424
+ }
425
+
426
+ attributes.merge!(@tags) if @tags
427
+
428
+ Traces.trace('async.pool.release', attributes: attributes) {super}
420
429
  end
421
430
 
422
431
  def retire(...)
423
- super.tap do
424
- RETIRE_COUNT.emit(1)
425
- end
432
+ attributes = {
433
+ size: @resources.size,
434
+ }
435
+
436
+ attributes.merge!(@tags) if @tags
437
+
438
+ Traces.trace('async.pool.retire', attributes: attributes) {super}
426
439
  end
427
440
  end
428
441
  end
@@ -3,10 +3,10 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require 'console/logger'
6
+ require "console/logger"
7
7
 
8
- require 'async/notification'
9
- require 'async/semaphore'
8
+ require "async/notification"
9
+ require "async/semaphore"
10
10
 
11
11
  module Async
12
12
  module Pool
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Pool
8
- VERSION = "0.8.1"
8
+ VERSION = "0.10.1"
9
9
  end
10
10
  end
data/lib/async/pool.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
- require_relative 'pool/version'
7
- require_relative 'pool/controller'
6
+ require_relative "pool/version"
7
+ require_relative "pool/controller"
8
8
 
9
9
  # @namespace
10
10
  module Async
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.8.1
4
+ version: 0.10.1
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-08-26 00:00:00.000000000 Z
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