Documentation
¶
Overview ¶
Package state contains logic for managing registry state which the server persists.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRegistryNotFound = errors.New("registry not found")
ErrRegistryNotFound is returned when a registry can't be found.
Functions ¶
This section is empty.
Types ¶
type RegistryStateService ¶
type RegistryStateService interface {
// Initialize populates the state store with the set of registries.
// It is intended that this is called at application startup, and it
// will overwrite any previous state.
Initialize(ctx context.Context, registryConfigs []config.RegistryConfig) error
// ListSyncStatuses lists all available sync statuses.
ListSyncStatuses(ctx context.Context) (map[string]*status.SyncStatus, error)
// GetSyncStatus lists the status of the named registry.
GetSyncStatus(ctx context.Context, registryName string) (*status.SyncStatus, error)
// UpdateSyncStatus overrides the value of the named registry with the syncStatus parameter.
UpdateSyncStatus(ctx context.Context, registryName string, syncStatus *status.SyncStatus) error
// GetNextSyncJob returns the next registry configuration that needs syncing.
// The predicate function is used to filter registries based on their config and sync status.
// The registry configs are cached from the Initialize call.
GetNextSyncJob(
ctx context.Context,
predicate func(*config.RegistryConfig, *status.SyncStatus) bool,
) (*config.RegistryConfig, error)
}
RegistryStateService provides methods for inspecting the sync state of a service.
func NewDBStateService ¶ added in v0.3.1
func NewDBStateService(pool *pgxpool.Pool) RegistryStateService
NewDBStateService creates a new database-backed registry state service
func NewFileStateService ¶
func NewFileStateService(statusPersistence status.StatusPersistence) RegistryStateService
NewFileStateService creates a new file-based registry state service
func NewStateService ¶ added in v0.3.2
func NewStateService( cfg *config.Config, statusPersistence status.StatusPersistence, pool *pgxpool.Pool, ) (RegistryStateService, error)
NewStateService creates a RegistryStateService based on the configured storage type.
For file-based storage, it returns a FileStateService that uses the provided StatusPersistence for persisting sync status to disk.
For database storage, it returns a DBStateService that stores sync status directly in PostgreSQL. The pool parameter must not be nil when database storage is configured.
Returns an error if database storage is configured but the pool is nil.