Documentation
¶
Overview ¶
Package pg is a Postgres-backed dispatch.Store for the hosted control plane. The OSS single-host controller uses the in-memory + JSONL *dispatch.Ledger; the hosted control plane points at Neon so dispatch state survives Fly machine restarts and the web app can read it. Same contract either way.
Index ¶
- type Store
- func (s *Store) Claim(id string, at time.Time, wantOrgs []string) (dispatch.Record, bool, error)
- func (s *Store) Close()
- func (s *Store) ExpireOffer(id string) bool
- func (s *Store) Offer(r dispatch.Record) error
- func (s *Store) Resolve(id, _ string, wantOrgs []string) (dispatch.Record, bool, error)
- func (s *Store) Snapshot() []dispatch.Record
- func (s *Store) Start(id, agent string, wantOrgs []string) (dispatch.Record, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements dispatch.Store against Postgres. Resolving deletes the row, so every row is a live dispatch and the partial unique index gives the same one-unstarted-dispatch-per-job dedup as the JSONL ledger.
func NewWithPool ¶
NewWithPool applies the schema on an existing pool and returns a Store sharing it (the caller owns the pool's lifetime — used to share one pool with enroll).
func (*Store) Claim ¶
Claim transitions offered -> claimed. ok is false if the record is unknown, not offered (double claim), or owned by another tenant (org not in wantOrgs).
func (*Store) ExpireOffer ¶
ExpireOffer deletes id only if it is still offered (see Store.ExpireOffer).
func (*Store) Offer ¶
Offer inserts a new offered record. A duplicate id or (org, job_id) returns dispatch.ErrDuplicate so the server can distinguish it from an I/O error.
func (*Store) Resolve ¶
Resolve removes a live record in any state. ok is false if it is unknown (already resolved) or owned by another tenant (org not in wantOrgs). status is not persisted — the row is deleted.