Class: Familia::Connection::FiberTransactionHandler

Inherits:
BaseConnectionHandler show all
Defined in:
lib/familia/connection/handlers.rb

Overview

Checks for fiber-local transaction connections (highest priority for Horreum)

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.

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 Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Familia::Connection::BaseConnectionHandler

Class Method Details

.instanceObject



184
185
186
# File 'lib/familia/connection/handlers.rb', line 184

def self.instance
  @instance
end

Instance Method Details

#handle(_uri) ⇒ Object



188
189
190
191
192
193
# File 'lib/familia/connection/handlers.rb', line 188

def handle(_uri)
  return nil unless Fiber[:familia_transaction]

  Familia.trace :DBCLIENT_FIBER_TRANSACTION, nil, 'Using fiber-local transaction connection'
  Fiber[:familia_transaction]
end