Class: Mammoth::Sources::PostgresSlotHealth
- Inherits:
-
Object
- Object
- Mammoth::Sources::PostgresSlotHealth
- Defined in:
- lib/mammoth/sources/postgres_slot_health.rb
Overview
Immutable operator-facing health snapshot for one PostgreSQL replication slot.
This is a Mammoth-owned policy view. The transport layer supplies catalog facts; Mammoth decides whether they make the configured source ready for continuous delivery. Typed PostgreSQL slot health and readiness policy.
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#confirmed_flush_lsn ⇒ Object
readonly
Returns the value of attribute confirmed_flush_lsn.
-
#confirmed_flush_lsn_bytes ⇒ Object
readonly
Returns the value of attribute confirmed_flush_lsn_bytes.
-
#conflicting ⇒ Object
readonly
Returns the value of attribute conflicting.
-
#inactive_since ⇒ Object
readonly
Returns the value of attribute inactive_since.
-
#invalidation_reason ⇒ Object
readonly
Returns the value of attribute invalidation_reason.
-
#present ⇒ Object
readonly
Returns the value of attribute present.
-
#restart_lsn ⇒ Object
readonly
Returns the value of attribute restart_lsn.
-
#restart_lsn_bytes ⇒ Object
readonly
Returns the value of attribute restart_lsn_bytes.
-
#retained_wal_bytes ⇒ Object
readonly
Returns the value of attribute retained_wal_bytes.
-
#safe_wal_size ⇒ Object
readonly
Returns the value of attribute safe_wal_size.
-
#slot_name ⇒ Object
readonly
Returns the value of attribute slot_name.
-
#wal_status ⇒ Object
readonly
Returns the value of attribute wal_status.
Class Method Summary collapse
-
.missing(slot_name) ⇒ PostgresSlotHealth
Build a snapshot for a missing configured slot.
Instance Method Summary collapse
-
#initialize(slot_name:, present:, active:, retained_wal_bytes:, wal_status:, safe_wal_size:, inactive_since:, invalidation_reason:, restart_lsn:, restart_lsn_bytes:, confirmed_flush_lsn:, confirmed_flush_lsn_bytes:, conflicting:) ⇒ void
constructor
Build a PostgreSQL slot health snapshot from normalized catalog facts.
-
#ready? ⇒ Boolean
Whether the slot is present, active, and retaining usable WAL.
-
#reason ⇒ String?
Operator-facing reason the slot is not ready.
-
#summary ⇒ Hash
Stable readiness payload without transport-library types.
Constructor Details
#initialize(slot_name:, present:, active:, retained_wal_bytes:, wal_status:, safe_wal_size:, inactive_since:, invalidation_reason:, restart_lsn:, restart_lsn_bytes:, confirmed_flush_lsn:, confirmed_flush_lsn_bytes:, conflicting:) ⇒ void
Build a PostgreSQL slot health snapshot from normalized catalog facts.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 19 def initialize(slot_name:, present:, active:, retained_wal_bytes:, wal_status:, safe_wal_size:, inactive_since:, invalidation_reason:, restart_lsn:, restart_lsn_bytes:, confirmed_flush_lsn:, confirmed_flush_lsn_bytes:, conflicting:) @slot_name = slot_name @present = present @active = active @retained_wal_bytes = retained_wal_bytes @wal_status = wal_status @safe_wal_size = safe_wal_size @inactive_since = inactive_since @invalidation_reason = invalidation_reason @restart_lsn = restart_lsn @restart_lsn_bytes = restart_lsn_bytes @confirmed_flush_lsn = confirmed_flush_lsn @confirmed_flush_lsn_bytes = confirmed_flush_lsn_bytes @conflicting = conflicting freeze end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def active @active end |
#confirmed_flush_lsn ⇒ Object (readonly)
Returns the value of attribute confirmed_flush_lsn.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def confirmed_flush_lsn @confirmed_flush_lsn end |
#confirmed_flush_lsn_bytes ⇒ Object (readonly)
Returns the value of attribute confirmed_flush_lsn_bytes.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def confirmed_flush_lsn_bytes @confirmed_flush_lsn_bytes end |
#conflicting ⇒ Object (readonly)
Returns the value of attribute conflicting.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def conflicting @conflicting end |
#inactive_since ⇒ Object (readonly)
Returns the value of attribute inactive_since.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def inactive_since @inactive_since end |
#invalidation_reason ⇒ Object (readonly)
Returns the value of attribute invalidation_reason.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def invalidation_reason @invalidation_reason end |
#present ⇒ Object (readonly)
Returns the value of attribute present.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def present @present end |
#restart_lsn ⇒ Object (readonly)
Returns the value of attribute restart_lsn.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def restart_lsn @restart_lsn end |
#restart_lsn_bytes ⇒ Object (readonly)
Returns the value of attribute restart_lsn_bytes.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def restart_lsn_bytes @restart_lsn_bytes end |
#retained_wal_bytes ⇒ Object (readonly)
Returns the value of attribute retained_wal_bytes.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def retained_wal_bytes @retained_wal_bytes end |
#safe_wal_size ⇒ Object (readonly)
Returns the value of attribute safe_wal_size.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def safe_wal_size @safe_wal_size end |
#slot_name ⇒ Object (readonly)
Returns the value of attribute slot_name.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def slot_name @slot_name end |
#wal_status ⇒ Object (readonly)
Returns the value of attribute wal_status.
12 13 14 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 12 def wal_status @wal_status end |
Class Method Details
.missing(slot_name) ⇒ PostgresSlotHealth
Build a snapshot for a missing configured slot.
42 43 44 45 46 47 48 49 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 42 def self.missing(slot_name) new( slot_name:, present: false, active: false, retained_wal_bytes: nil, wal_status: nil, safe_wal_size: nil, inactive_since: nil, invalidation_reason: nil, restart_lsn: nil, restart_lsn_bytes: nil, confirmed_flush_lsn: nil, confirmed_flush_lsn_bytes: nil, conflicting: false ) end |
Instance Method Details
#ready? ⇒ Boolean
Whether the slot is present, active, and retaining usable WAL.
54 55 56 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 54 def ready? reason.nil? end |
#reason ⇒ String?
Operator-facing reason the slot is not ready.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 61 def reason return "slot is missing" unless present return "slot is inactive" unless active return "wal_status=#{wal_status}" if %w[lost unreserved].include?(wal_status) return "slot is invalidated: #{invalidation_reason}" unless blank?(invalidation_reason) return "slot is conflicting" if conflicting return "slot has no restart LSN" if blank?(restart_lsn) nil end |
#summary ⇒ Hash
Stable readiness payload without transport-library types.
75 76 77 78 79 80 81 |
# File 'lib/mammoth/sources/postgres_slot_health.rb', line 75 def summary { slot_name:, present:, active:, retained_wal_bytes:, wal_status:, safe_wal_size:, inactive_since:, invalidation_reason:, restart_lsn:, restart_lsn_bytes:, confirmed_flush_lsn:, confirmed_flush_lsn_bytes:, conflicting:, ready: ready?, reason: } end |