Class: Pgbus::ProcessedEvent

Inherits:
BusRecord
  • Object
show all
Defined in:
app/models/pgbus/processed_event.rb

Class Method Summary collapse

Class Method Details

.completion_column?Boolean

Whether pgbus_processed_events has the completed_at column that backs the two-phase idempotency claim (issue #385). Detected once per process (memoized under a mutex) so the schema probe never lands on the per-event hot path. An upgraded gem running against a not-yet-migrated table gets false plus a one-time warning pointing at the upgrade generator — Handler then falls back to the legacy single-phase claim.

A detection error (e.g. the database is briefly unreachable) is NOT memoized: it propagates to the caller — where the event's normal failure path leaves the message for VT redelivery — and the next delivery probes again.

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'app/models/pgbus/processed_event.rb', line 23

def completion_column?
  detected = @completion_column
  return detected unless detected.nil?

  @completion_column_mutex.synchronize do
    @completion_column = detect_completion_column if @completion_column.nil?
    @completion_column
  end
end

.reset_completion_column_check!Object

Test seam: clear the memoized detection so specs can exercise both schema shapes in one process.



35
36
37
# File 'app/models/pgbus/processed_event.rb', line 35

def reset_completion_column_check!
  @completion_column_mutex.synchronize { @completion_column = nil }
end