ros-apartment 4.0.0.alpha4 → 4.0.0.alpha5

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: 86ded64305e44aac057b97264c079d5090545b7d1740693ea1cf7c881b69fe19
4
- data.tar.gz: 99e78891808ff4cdb1e0fef82f7c49a344a4c088408c9c143af465c70a150a3b
3
+ metadata.gz: c4e597c986618a8043acbecc8081ef0399493c545fd3720d8f57653da90025da
4
+ data.tar.gz: 9fb0d04fe5abb04e93a4ef654edc14744dfc8d86d35f6d6ef8b685d7eb6ddb29
5
5
  SHA512:
6
- metadata.gz: 6a80e29d57f2d4d4de7cd41666b3cef737720cceb782c3d6a34f5522dec0a6ec3fc04e41ba1a45761eabfee5bee5f5b0d2d80d2ae79d1c43f8d905906d7dc1d3
7
- data.tar.gz: a4c460e9ec3c2214e1a52fd399bf0038a6da1d43c66a20fbd97a31ceb6ac44b4595592eec41f0310cfc51f99e5b6699420332fa816a177865479af1772dea928
6
+ metadata.gz: 747e6efe4c8c073368684944bbee84cccfd0b063f389d7b4a699debd97662496db9ea220e6be6f119986fa76e3586d180bb3f61ff61c4c44bc3acc37b7784f0c
7
+ data.tar.gz: 9ceef5927c8169dc2db2041fbbfba99b81c7106a9cf02814812550c1775cd2566398dd8383e78bd0d24e7a82a845d2c4418bc974c43cc5e0169cd25a6072eba5
@@ -24,7 +24,18 @@ module Apartment
24
24
  def self.install!(sink:, sample_interval: nil, backend_count: nil)
25
25
  observer = new(sink: sink, backend_count: backend_count)
26
26
  observer.subscribe!
27
- observer.start_sampler!(interval: sample_interval) if sample_interval&.positive?
27
+ if sample_interval.nil?
28
+ # nil is the intentional "no gauge sampler" signal; counters still flow.
29
+ elsif sample_interval.positive?
30
+ observer.start_sampler!(interval: sample_interval)
31
+ else
32
+ # A non-nil, non-positive interval is almost always a misconfig (e.g. an
33
+ # empty APARTMENT_POOL_SAMPLE_INTERVAL coerced to 0). Silently skipping
34
+ # the sampler ships an observer whose gauges never emit; surface it.
35
+ warn "[Apartment::PoolObserver] sample_interval=#{sample_interval.inspect} is not " \
36
+ 'positive; gauge sampler not started (tenant_pools_live/backend_connections ' \
37
+ 'will not emit). Pass a positive interval, or nil to disable the sampler.'
38
+ end
28
39
  observer
29
40
  rescue StandardError
30
41
  # Don't leak subscriptions if a later step (e.g. a bad sample_interval)
@@ -200,17 +200,29 @@ module Apartment
200
200
  # it drops EVERY connection leased to the current execution context, across
201
201
  # all pools and roles, not just the tenant pool. Do NOT use it inside an
202
202
  # outer ActiveRecord::Base.transaction, or while holding a non-tenant
203
- # connection you mean to keep. Fail-fast: if the block raises, the failing
204
- # tenant is not released (the fan-out aborts).
203
+ # connection you mean to keep. Fail-fast: a raising block still aborts the
204
+ # fan-out, but the failing tenant's connection is released first the
205
+ # release is best-effort cleanup (in an ensure), not iteration semantics.
205
206
  def each(tenants = nil, release_connection: false)
206
207
  raise(ArgumentError, 'Apartment::Tenant.each requires a block') unless block_given?
207
208
 
208
209
  tenants ||= Apartment.tenant_names
209
210
  tenants.each do |tenant|
210
211
  switch(tenant) { yield(tenant) }
212
+ ensure
211
213
  # Handler-wide (:all) covers writing + reading roles — the gem's
212
- # established release call (see memory_stability_spec).
213
- ActiveRecord::Base.connection_handler.clear_active_connections!(:all) if release_connection
214
+ # established release call (see memory_stability_spec). In an ensure so
215
+ # a raising tenant is still released; the exception then propagates and
216
+ # halts the fan-out (fail-fast preserved). Best-effort: a release
217
+ # failure must never mask the block's exception, so it is rescued and
218
+ # warned rather than raised out of the ensure.
219
+ if release_connection
220
+ begin
221
+ ActiveRecord::Base.connection_handler.clear_active_connections!(:all)
222
+ rescue StandardError => e
223
+ warn("[Apartment::Tenant.each] connection release failed: #{e.class}: #{e.message}")
224
+ end
225
+ end
214
226
  end
215
227
  end
216
228
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apartment
4
- VERSION = '4.0.0.alpha4'
4
+ VERSION = '4.0.0.alpha5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ros-apartment
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.alpha4
4
+ version: 4.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner