async-service-supervisor 0.19.0 → 0.20.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: 537a7bbe49f8304f907d4b258931dd3de900c591d781dd305b0daa8c285d4432
4
- data.tar.gz: 2a1da9aa30958fd2628312aa053aaf2f6d61215689761c6bf8247b9e09510b4b
3
+ metadata.gz: fb8f5a6980d5ea448b4e4ec8826590167195c4fc31c3d40d2ba3e79e118bc270
4
+ data.tar.gz: 47bf75e14cfb55cba7007b50cea7029151bd6c265ebf8d0547340b4e53b58a14
5
5
  SHA512:
6
- metadata.gz: 86c98af76a9bd87f0c31bdf590765ac3e851d259604f1a62e0a5df134943fce4bfccf67ddaa3870c4c202f34eae9eab0a71cbcc72879ec7191f868147c3ad8ba
7
- data.tar.gz: 7daac497ebd34ff0cd408bb34284979da4bb727a70e754be0b3c30e35ceaabefb60545523b9d47be9741551df2b54893d3535c44e612c9e7139f3b90298f726b
6
+ metadata.gz: 02b8bb2dada453bc5b96f48ae2608cd655c5eb0cfe22568c9aacd68efe798fcc25a3c652d7cfe94cdcf144676c7aa5d4a12b92f3f91ba6d0d419a2154c296991
7
+ data.tar.gz: 547604201a8a872e1498773e3ef6e472ed5a4970b5781c9fd6638802095e732d23bf5049332a8bb9d1cfdab0699421d50a52abff2f3ecc701a1d2366c5acadb8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -281,35 +281,48 @@ module Async
281
281
  #
282
282
  # @returns [Hash] Hash mapping service names to aggregated utilization metrics.
283
283
  def sample
284
- @guard.synchronize do
285
- aggregated = {}
284
+ aggregated = {}
285
+
286
+ sample_by_worker.each_value do |worker|
287
+ service_name = worker[:state][:name] || "unknown"
286
288
 
287
- @workers.each do |worker_id, supervisor_controller|
288
- service_name = supervisor_controller.state[:name] || "unknown"
289
-
290
- data = @allocator.read(worker_id)
291
- next unless data
292
-
293
- # Initialize service aggregation if needed
294
- aggregated[service_name] ||= {}
295
-
296
- # Sum up all numeric fields
297
- data.each do |key, value|
298
- if value.is_a?(Numeric)
299
- aggregated[service_name][key] ||= 0
300
- aggregated[service_name][key] += value
301
- else
302
- # For non-numeric values, we could handle differently
303
- # For now, just store the last value
304
- aggregated[service_name][key] = value
305
- end
289
+ data = worker[:utilization]
290
+
291
+ # Initialize service aggregation if needed
292
+ aggregated[service_name] ||= {}
293
+
294
+ # Sum up all numeric fields
295
+ data.each do |key, value|
296
+ if value.is_a?(Numeric)
297
+ aggregated[service_name][key] ||= 0
298
+ aggregated[service_name][key] += value
299
+ else
300
+ # For non-numeric values, we could handle differently
301
+ # For now, just store the last value
302
+ aggregated[service_name][key] = value
306
303
  end
307
-
308
- # Count workers per service (for utilization denominator)
309
- aggregated[service_name][:worker_count] = (aggregated[service_name][:worker_count] || 0) + 1
310
304
  end
311
305
 
312
- aggregated
306
+ # Count workers per service (for utilization denominator)
307
+ aggregated[service_name][:worker_count] = (aggregated[service_name][:worker_count] || 0) + 1
308
+ end
309
+
310
+ aggregated
311
+ end
312
+
313
+ # Sample utilization data for each registered worker.
314
+ #
315
+ # @returns [Hash] An immutable hash keyed by worker ID, with supervisor state and utilization values.
316
+ def sample_by_worker
317
+ @guard.synchronize do
318
+ @workers.each_with_object({}) do |(worker_id, supervisor_controller), workers|
319
+ if utilization = @allocator.read(worker_id)
320
+ workers[worker_id] = {
321
+ state: supervisor_controller.state.dup.freeze,
322
+ utilization: utilization.freeze,
323
+ }.freeze
324
+ end
325
+ end.freeze
313
326
  end
314
327
  end
315
328
 
@@ -9,7 +9,7 @@ module Async
9
9
  module Service
10
10
  # @namespace
11
11
  module Supervisor
12
- VERSION = "0.19.0"
12
+ VERSION = "0.20.0"
13
13
  end
14
14
  end
15
15
  end
data/readme.md CHANGED
@@ -30,6 +30,10 @@ Please see the [project documentation](https://socketry.github.io/async-service-
30
30
 
31
31
  Please see the [project releases](https://socketry.github.io/async-service-supervisor/releases/index) for all releases.
32
32
 
33
+ ### v0.20.0
34
+
35
+ - Add per-worker snapshots to `Async::Service::Supervisor::UtilizationMonitor`.
36
+
33
37
  ### v0.18.0
34
38
 
35
39
  - Allow supervised services to merge additional worker state during preparation and worker construction.
@@ -68,13 +72,6 @@ Please see the [project releases](https://socketry.github.io/async-service-super
68
72
  - Add `state` parameter to `Worker#initialize` to allow workers to provide state during registration.
69
73
  - State is now accessible via `supervisor_controller.state` instead of `connection.state` (as it was in `Async::Container::Supervisor`).
70
74
 
71
- ### v0.10.0
72
-
73
- - Serialize `register`/`remove` and `check!` operations in `MemoryMonitor` to prevent race conditions.
74
- - Remove `memory_sample` functionality - it wasn't very useful and added a lot of complexity.
75
- - Add support for `Memory::Leak::Cluster` `free_size_minimum:` option.
76
- - Remove extraneous "Memory leak detected\!" logs.
77
-
78
75
  ## Contributing
79
76
 
80
77
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.20.0
4
+
5
+ - Add per-worker snapshots to `Async::Service::Supervisor::UtilizationMonitor`.
6
+
3
7
  ## v0.18.0
4
8
 
5
9
  - Allow supervised services to merge additional worker state during preparation and worker construction.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-service-supervisor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file