Class: Familia::Connection::FiberPipelineHandler

Inherits:
Object
  • Object
show all
Includes:
Handler
Defined in:
lib/familia/connection/handlers.rb

Overview

Checks for fiber-local pipeline connections

Returns the fiber-local pipeline connection when inside a pipelined block. Raises ConflictingContextError if both pipeline and transaction contexts are active — these are mutually exclusive operations.

Reentrant pipeline - just yield the existing connection No new pipeline block, just participate in existing pipeline

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.instance ⇒ Object (readonly)

Returns the value of attribute instance.



217
218
219
# File 'lib/familia/connection/handlers.rb', line 217

def instance
  @instance
end

Instance Method Details

#handle(_uri) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/familia/connection/handlers.rb', line 220

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

  if Fiber[:familia_transaction]
    Familia.trace :CONFLICTING_CONTEXT, _uri,
                 'Pipeline handler detected active transaction context'
    raise Familia::ConflictingContextError,
      'Cannot mix pipeline and transaction contexts. ' \
      'Restructure to use one or the other.'
  end

  Familia.trace :DBCLIENT_FIBER_PIPELINE, nil, 'Using fiber-local pipeline connection'
  Fiber[:familia_pipeline]
end