Class: Pgbus::Process::ReadinessSnapshot

Inherits:
Data
  • Object
show all
Defined in:
lib/pgbus/process/readiness_snapshot.rb

Overview

Immutable container-local readiness state, published by the supervisor (one atomic swap per monitor pass) and read by the standalone health server's accept thread — the immutability is what makes the cross-thread handoff safe without a lock (issue #386).

expected is the child count forked by boot_processes; live is the current fork-table size. A child sitting in crash-restart backoff keeps live < expected, which is exactly the signal a rolling deploy's health gate needs to fail on: the replacement container never goes ready, and the orchestrator keeps the old container running.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bootedObject (readonly)

Returns the value of attribute booted

Returns:

  • (Object)

    the current value of booted



15
16
17
# File 'lib/pgbus/process/readiness_snapshot.rb', line 15

def booted
  @booted
end

#expectedObject (readonly)

Returns the value of attribute expected

Returns:

  • (Object)

    the current value of expected



15
16
17
# File 'lib/pgbus/process/readiness_snapshot.rb', line 15

def expected
  @expected
end

#liveObject (readonly)

Returns the value of attribute live

Returns:

  • (Object)

    the current value of live



15
16
17
# File 'lib/pgbus/process/readiness_snapshot.rb', line 15

def live
  @live
end

#shutting_downObject (readonly)

Returns the value of attribute shutting_down

Returns:

  • (Object)

    the current value of shutting_down



15
16
17
# File 'lib/pgbus/process/readiness_snapshot.rb', line 15

def shutting_down
  @shutting_down
end

Instance Method Details

#ready?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/pgbus/process/readiness_snapshot.rb', line 16

def ready?
  booted && !shutting_down && live >= expected
end

#statusObject

DRAINING wins over BOOTING: a supervisor told to stop mid-boot is leaving, not arriving, and must never look like it will become ready.



22
23
24
25
26
27
# File 'lib/pgbus/process/readiness_snapshot.rb', line 22

def status
  return "DRAINING" if shutting_down
  return "BOOTING" unless booted

  ready? ? "OK" : "DEGRADED"
end