async-pool 0.4.0 → 0.6.0

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: 90ad67ae4201f83d1a5c9767b425ce1223d0b4d9c068a1046c98948875ec4c15
4
- data.tar.gz: 84b8d54ad04302b935f65ca5e13c5929bda43bcf95754db9568f4c99ae7d5e92
3
+ metadata.gz: 30797072f6201029b50156bd2b6f9ef035790e084a81449b906800a1fb6bcb33
4
+ data.tar.gz: d29642965319848394b3d5a2712bfe5a139fac48ec6263029b25b52e9d9fd32b
5
5
  SHA512:
6
- metadata.gz: 3871fcd341afbc5db9af1f6e70ff6b58aeca070f9f8e89a5c4680e20feb33baa4c5d4c946bf2378fc526fa2dc021648ba0ec2b34b08a0de6cf2205ea6065b88f
7
- data.tar.gz: 32f66fb6d31ab5413dd104061fd0afc8b3fdfb07d1644a3d315ac40c469cb985d976da393e9b54fb13fd6fff5b5a2680f7c0f00a506c52c735a068e074f890d1
6
+ metadata.gz: 975f7735a49f0853287bbad466aadf91e0d6b896cdb2c6d88336d94f1d4cee9c227ef8cf4ea63dcc118ca1b709ce109622d8e89f1d90d951d1ea1f261dcfa854
7
+ data.tar.gz: 7a75ec0f2d2506b85bc61ec60f3da503ddcfb5277c2390398d5a7b5834cee33b01651405f134e3c80865a5f87a975754f21cceeee1a4a2797f24c9f8efb74948
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
  # Copyright, 2020, by Simon Perepelitsa.
6
+ # Copyright, 2024, by Thomas Morgan.
6
7
 
7
8
  require 'console/logger'
8
9
 
@@ -44,6 +45,27 @@ module Async
44
45
  # @attribute [Integer] The maximum number of resources that this pool can have at any given time.
45
46
  attr_accessor :limit
46
47
 
48
+ def to_s
49
+ if @resources.empty?
50
+ "\#<#{self.class}(#{usage_string})>"
51
+ else
52
+ "\#<#{self.class}(#{usage_string}) #{availability_summary.join(';')}>"
53
+ end
54
+ end
55
+
56
+ def as_json(...)
57
+ {
58
+ limit: @limit,
59
+ concurrency: @guard.limit,
60
+ usage: @resources.size,
61
+ availability_summary: self.availability_summary,
62
+ }
63
+ end
64
+
65
+ def to_json(...)
66
+ as_json.to_json(...)
67
+ end
68
+
47
69
  # @attribute [Integer] The maximum number of concurrent tasks that can be creating a new resource.
48
70
  def concurrency
49
71
  @guard.limit
@@ -133,14 +155,6 @@ module Async
133
155
  @gardener&.stop
134
156
  end
135
157
 
136
- def to_s
137
- if @resources.empty?
138
- "\#<#{self.class}(#{usage_string})>"
139
- else
140
- "\#<#{self.class}(#{usage_string}) #{availability_string}>"
141
- end
142
- end
143
-
144
158
  # Retire (and close) all unused resources. If a block is provided, it should implement the desired functionality for unused resources.
145
159
  # @param retain [Integer] the minimum number of resources to retain.
146
160
  # @yield resource [Resource] unused resources.
@@ -156,10 +170,12 @@ module Async
156
170
 
157
171
  # It's okay for this to context switch:
158
172
  unused.each do |resource|
159
- if block_given?
160
- yield resource
161
- else
162
- retire(resource)
173
+ if usage = @resources[resource] and usage.zero?
174
+ if block_given?
175
+ yield resource
176
+ else
177
+ retire(resource)
178
+ end
163
179
  end
164
180
 
165
181
  break if @resources.size <= retain
@@ -215,10 +231,10 @@ module Async
215
231
  "#{@resources.size}/#{@limit || '∞'}"
216
232
  end
217
233
 
218
- def availability_string
234
+ def availability_summary
219
235
  @resources.collect do |resource, usage|
220
236
  "#{usage}/#{resource.concurrency}#{resource.viable? ? nil : '*'}/#{resource.count}"
221
- end.join(";")
237
+ end
222
238
  end
223
239
 
224
240
  # def usage
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  module Pool
8
- VERSION = "0.4.0"
8
+ VERSION = "0.6.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2023, by Samuel Williams.
3
+ Copyright, 2019-2024, by Samuel Williams.
4
4
  Copyright, 2020, by Simon Perepelitsa.
5
5
  Copyright, 2021, by Olle Jonsson.
6
+ Copyright, 2024, by Thomas Morgan.
6
7
 
7
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
9
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -52,3 +52,11 @@ We welcome contributions to this project.
52
52
  3. Commit your changes (`git commit -am 'Add some feature'`).
53
53
  4. Push to the branch (`git push origin my-new-feature`).
54
54
  5. Create new Pull Request.
55
+
56
+ ### Developer Certificate of Origin
57
+
58
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
59
+
60
+ ### Contributor Covenant
61
+
62
+ This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Olle Jonsson
9
9
  - Simon Perepelitsa
10
+ - Thomas Morgan
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain:
@@ -39,7 +40,7 @@ cert_chain:
39
40
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
40
41
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
41
42
  -----END CERTIFICATE-----
42
- date: 2023-03-12 00:00:00.000000000 Z
43
+ date: 2024-04-22 00:00:00.000000000 Z
43
44
  dependencies:
44
45
  - !ruby/object:Gem::Dependency
45
46
  name: async
@@ -55,90 +56,6 @@ dependencies:
55
56
  - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: '1.25'
58
- - !ruby/object:Gem::Dependency
59
- name: bake-test
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: bake-test-external
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- - !ruby/object:Gem::Dependency
87
- name: bundler
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- - !ruby/object:Gem::Dependency
101
- name: covered
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
- type: :development
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: '0'
114
- - !ruby/object:Gem::Dependency
115
- name: sus
116
- requirement: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: '0.15'
121
- type: :development
122
- prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '0.15'
128
- - !ruby/object:Gem::Dependency
129
- name: sus-fixtures-async
130
- requirement: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: '0'
135
- type: :development
136
- prerelease: false
137
- version_requirements: !ruby/object:Gem::Requirement
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
59
  description:
143
60
  email:
144
61
  executables: []
@@ -155,7 +72,9 @@ homepage: https://github.com/socketry/async-pool
155
72
  licenses:
156
73
  - MIT
157
74
  metadata:
75
+ documentation_uri: https://socketry.github.io/async-pool/
158
76
  funding_uri: https://github.com/sponsors/ioquatix/
77
+ source_code_uri: https://github.com/socketry/async-pool.git
159
78
  post_install_message:
160
79
  rdoc_options: []
161
80
  require_paths:
@@ -164,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
83
  requirements:
165
84
  - - ">="
166
85
  - !ruby/object:Gem::Version
167
- version: '2.5'
86
+ version: '3.1'
168
87
  required_rubygems_version: !ruby/object:Gem::Requirement
169
88
  requirements:
170
89
  - - ">="
171
90
  - !ruby/object:Gem::Version
172
91
  version: '0'
173
92
  requirements: []
174
- rubygems_version: 3.4.7
93
+ rubygems_version: 3.5.3
175
94
  signing_key:
176
95
  specification_version: 4
177
96
  summary: A singleplex and multiplex resource pool for implementing robust clients.
metadata.gz.sig CHANGED
Binary file