Documentation
¶
Overview ¶
Package status keeps the latest status the renderer reported for each service of each preview. Memory is the source of truth for reads; with a Persistence, each preview's status is also written at most once per flush interval and read back on start.
Index ¶
- type Lister
- type Persistence
- type Store
- func (s *Store) Close(ctx context.Context)
- func (s *Store) CollectGarbage()
- func (s *Store) Delete(slugs ...string)
- func (s *Store) Load(ctx context.Context) error
- func (s *Store) Preview(slug string) map[string]preview.ServiceStatus
- func (s *Store) Record(slug, service string, e preview.ServiceStatus) (bool, bool)
- func (s *Store) Start(ctx context.Context, lister Lister)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Persistence ¶ added in v0.30.0
type Persistence interface {
// List returns, by preview, the persisted status of each service.
List(ctx context.Context) (map[string]map[string]preview.ServiceStatus, error)
// Names returns the previews that have persisted status.
Names(ctx context.Context) ([]string, error)
// Write persists the status snapshot returns for the preview slug,
// calling snapshot at each attempt and writing nothing once it reports
// the preview gone.
Write(ctx context.Context, slug string, snapshot func() (map[string]preview.ServiceStatus, bool)) error
// Delete removes the persisted status of slug, already absent being no
// error.
Delete(ctx context.Context, slug string) error
}
Persistence keeps each preview's status outside the process: internal/status/kube keeps it in ConfigMaps.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the status of every preview, in memory and, with a Kubernetes client, in ConfigMaps. Its methods are safe for concurrent use.
func NewPersisted ¶ added in v0.30.0
func NewPersisted(p Persistence) *Store
NewPersisted returns an empty Store persisted through p, which must not be nil.
func (*Store) Close ¶
Close stops what Start runs and, when s is persisted, deletes the queued ConfigMaps and writes the dirty previews once, within ctx.
func (*Store) CollectGarbage ¶
func (s *Store) CollectGarbage()
CollectGarbage asks for a garbage collection (collectGarbage) in the background, once Start ran. It does not wait: requests made while one runs make one more run.
func (*Store) Delete ¶
Delete forgets the status of the previews slugs and queues the deletion of their ConfigMaps. It does not wait for Kubernetes.
func (*Store) Load ¶
Load reads every preview's status back from its ConfigMap. It reads nothing when s is memory-only. A failed listing is returned.
func (*Store) Preview ¶
func (s *Store) Preview(slug string) map[string]preview.ServiceStatus
Preview returns the status of the services of the preview slug, by service; none when nothing is known.