Class: Familia::Connection::FiberTransactionHandler
- Inherits:
-
Object
- Object
- Familia::Connection::FiberTransactionHandler
- Includes:
- Handler
- Defined in:
- lib/familia/connection/handlers.rb
Overview
Checks for fiber-local transaction connections
Key insight: Mark that we're in reentrant mode and also track of depth. This allows nested transaction calls to be safely reentrant without breaking Redis's single-level MULTI/EXEC.
Raises ConflictingContextError if both pipeline and transaction contexts are active — these are mutually exclusive operations.
Reentrant transaction - just yield the existing connection No new MULTI/EXEC, just participate in existing transaction Fiber[:familia_transaction_depth] ||= 0 Fiber[:familia_transaction_depth] += 1
Class Attribute Summary collapse
-
.instance ⇒ Object
readonly
Returns the value of attribute instance.
Instance Method Summary collapse
Class Attribute Details
.instance ⇒ Object (readonly)
Returns the value of attribute instance.
258 259 260 |
# File 'lib/familia/connection/handlers.rb', line 258 def instance @instance end |
Instance Method Details
#handle(_uri) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/familia/connection/handlers.rb', line 261 def handle(_uri) return nil unless Fiber[:familia_transaction] if Fiber[:familia_pipeline] Familia.trace :CONFLICTING_CONTEXT, _uri, 'Transaction handler detected active pipeline context' raise Familia::ConflictingContextError, 'Cannot mix pipeline and transaction contexts. ' \ 'Restructure to use one or the other.' end Familia.trace :DBCLIENT_FIBER_TRANSACTION, nil, 'Using fiber-local transaction connection' Fiber[:familia_transaction] end |