Module: Familia::Connection::TransactionCore
- Defined in:
- lib/familia/connection/transaction_core.rb
Overview
Core transaction logic shared between global and instance transaction methods
This module provides unified transaction handling with configurable fallback behavior when transactions are unavailable due to connection handler constraints. Eliminates code duplication between Operations and Horreum Connection modules.
Class Method Summary collapse
-
.execute_transaction(dbclient_proc, &block) {|Redis| ... } ⇒ MultiResult
Executes a transaction with configurable fallback behavior.
Class Method Details
.execute_transaction(dbclient_proc, &block) {|Redis| ... } ⇒ MultiResult
Executes a transaction with configurable fallback behavior
Handles three transaction scenarios based on connection handler capabilities:
- Normal transaction (MULTI/EXEC) when handler supports transactions
- Reentrant transaction when already within a transaction context
- Individual command execution with configurable error/warn/silent modes
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/familia/connection/transaction_core.rb', line 37 def self.execute_transaction(dbclient_proc, &block) # First, get the connection to populate the handler class connection = dbclient_proc.call handler_class = Fiber[:familia_connection_handler_class] # Check transaction capability transaction_capability = handler_class&.allows_transaction if transaction_capability == false handle_transaction_fallback(dbclient_proc, handler_class, &block) elsif transaction_capability == :reentrant # Already in transaction, just yield the connection yield(Fiber[:familia_transaction]) else # Normal transaction flow (includes nil, true, and other values) execute_normal_transaction(dbclient_proc, &block) end end |