Module: Apartment::Patches::ConnectionRegistry::HandlerSync
- Defined in:
- lib/apartment/patches/connection_registry.rb
Overview
Guards the handler's manager cache. set_pool_manager upserts with
||= on a Concurrent::Map: atomic per operation, but a read-then-write
across two, so two threads establishing the first connection for the same
connection name can each build a PoolManager and one is discarded —
silently taking any shard already registered in it with it. Serializing
the whole method makes the upsert atomic.
Wrapped with argument forwarding rather than a reimplementation because the signature is version-dependent (AR >= 8.0 passes a ConnectionDescriptor where 7.2 passed the connection-name String) and the key derivation is upstream's business, not ours.
Declared private to match upstream. A prepended method is public by default, and leaving it so would widen a Rails internal into public API from a patch whose only job is a lock.