Files
sam ae3bbc6cfe fix(app): serve only setup until the owner setup transaction commits
The binary started connectors, module routes, the starter workflow and the
worker loops at boot whatever the database said, so an instance with no owner
answered operational requests, the bootstrap admin token among them. The
governance module now signals once the bootstrap registration has committed,
and the composition root holds every operational route, connector and loop back
until it does. Liveness stays up and readiness reports the missing owner.
2026-11-21 03:40:02 +11:00

35 lines
905 B
Go

package governance
import "sync"
// SetupSignal reports that the owner setup transaction has committed. The
// composition root waits on it instead of polling the database for the change,
// and it fires once however many callers ask.
type SetupSignal struct {
once sync.Once
done chan struct{}
}
// NewSetupSignal returns a signal for a setup that has not committed yet.
func NewSetupSignal() *SetupSignal {
return &SetupSignal{done: make(chan struct{})}
}
// Complete records the commit. A second call, sequential or concurrent,
// changes nothing. A nil signal is a module built without durable state, as
// the API document is, and records nothing.
func (s *SetupSignal) Complete() {
if s == nil {
return
}
s.once.Do(func() { close(s.done) })
}
// Done is closed once the setup has committed.
func (s *SetupSignal) Done() <-chan struct{} {
if s == nil {
return nil
}
return s.done
}