Exception: Familia::IndexedFieldFastWriteError

Inherits:
PersistenceError show all
Defined in:
lib/familia/errors.rb

Overview

Raised when a fast-write method is asked to write a field that backs a class-level index and cannot run the index claim first, which the fail-closed ordering in ADR-0002 requires.

multi_field_fast_write raises it outside a transaction or pipeline, since its single HMSET leaves no room for the claim: use multi_field_update, save_fields or save there. A field! fast writer raises it inside a transaction or pipeline, where the claim cannot run and where multi_field_update, save_fields and save raise Familia::OperationModeError too: call field! or one of those methods before or after the block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, index_name, offenders: nil, inside_block: false) ⇒ IndexedFieldFastWriteError

Returns a new instance of IndexedFieldFastWriteError.

Parameters:

  • field (Symbol) —

    the (first) offending field

  • index_name (Symbol) —

    the index that field backs

  • offenders (Array<Array(Symbol, Symbol)>, nil) (defaults to: nil) —

    every (field, index_name) pair the caller found. The message names them all, so a batch write with several indexed fields is diagnosed in one pass instead of one retry per field. field/index_name stay the first pair for callers that predate the batch guard.

  • inside_block (Boolean) (defaults to: false) —

    whether the write was refused inside a transaction or pipeline, which changes the remedy the message gives



265
266
267
268
269
270
271
# File 'lib/familia/errors.rb', line 265

def initialize(field, index_name, offenders: nil, inside_block: false)
  @field = field
  @index_name = index_name
  @offenders = offenders || [[field, index_name]]
  @inside_block = inside_block
  super(build_message)
end

Instance Attribute Details

#field ⇒ Object (readonly)

Returns the value of attribute field.



254
255
256
# File 'lib/familia/errors.rb', line 254

def field
  @field
end

#index_name ⇒ Object (readonly)

Returns the value of attribute index_name.



254
255
256
# File 'lib/familia/errors.rb', line 254

def index_name
  @index_name
end

#inside_block ⇒ Object (readonly)

Returns the value of attribute inside_block.



254
255
256
# File 'lib/familia/errors.rb', line 254

def inside_block
  @inside_block
end

#offenders ⇒ Object (readonly)

Returns the value of attribute offenders.



254
255
256
# File 'lib/familia/errors.rb', line 254

def offenders
  @offenders
end