status

package
v0.4.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package status provides sync status tracking and persistence for the registry.

Index

Constants

View Source
const (
	// StatusFileName is the name of the status file
	StatusFileName = "status.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreationType added in v0.4.4

type CreationType string

CreationType represents how a registry was created

const (
	// CreationTypeAPI means the registry was created via the API
	CreationTypeAPI CreationType = "API"

	// CreationTypeCONFIG means the registry was created from configuration
	CreationTypeCONFIG CreationType = "CONFIG"
)

type StatusPersistence

type StatusPersistence interface {
	// SaveStatus saves the sync status to persistent storage for a specific registry
	SaveStatus(ctx context.Context, registryName string, status *SyncStatus) error

	// LoadStatus loads the sync status from persistent storage for a specific registry
	// Returns an empty SyncStatus if the file doesn't exist (first run)
	LoadStatus(ctx context.Context, registryName string) (*SyncStatus, error)

	// LoadAllStatus loads sync status for all registries
	LoadAllStatus(ctx context.Context) (map[string]*SyncStatus, error)
}

StatusPersistence defines the interface for sync status persistence

func NewFileStatusPersistence

func NewFileStatusPersistence(basePath string) StatusPersistence

NewFileStatusPersistence creates a new file-based status persistence basePath is the base directory where per-registry status files will be stored

type SyncPhase

type SyncPhase string

SyncPhase represents the current phase of a synchronization operation

const (
	// SyncPhaseSyncing means sync is currently in progress
	SyncPhaseSyncing SyncPhase = "Syncing"

	// SyncPhaseComplete means sync completed successfully
	SyncPhaseComplete SyncPhase = "Complete"

	// SyncPhaseFailed means sync failed
	SyncPhaseFailed SyncPhase = "Failed"
)

type SyncStatus

type SyncStatus struct {
	// Phase represents the current synchronization phase
	Phase SyncPhase `yaml:"phase"`

	// Message provides additional information about the sync status
	Message string `yaml:"message,omitempty"`

	// LastAttempt is the timestamp of the last sync attempt
	LastAttempt *time.Time `yaml:"lastAttempt,omitempty"`

	// AttemptCount is the number of sync attempts since last success
	AttemptCount int `yaml:"attemptCount,omitempty"`

	// LastSyncTime is the timestamp of the last successful sync
	LastSyncTime *time.Time `yaml:"lastSyncTime,omitempty"`

	// LastSyncHash is the hash of the last successfully synced data
	// Used to detect changes in source data
	LastSyncHash string `yaml:"lastSyncHash,omitempty"`

	// LastAppliedFilterHash is the hash of the last applied filter
	LastAppliedFilterHash string `yaml:"lastAppliedFilterHash,omitempty"`

	// ServerCount is the total number of servers in the registry
	ServerCount int `yaml:"serverCount,omitempty"`

	// CreationType indicates how this registry was created (API or CONFIG)
	// This prevents config-based sync from overwriting API-created registries
	CreationType CreationType `yaml:"creationType,omitempty"`

	// SyncSchedule is the sync interval from configuration (e.g., "30m", "1h")
	// This field is nullable - non-synced registries (managed, kubernetes) will have an empty value
	SyncSchedule string `yaml:"syncSchedule,omitempty"`
}

SyncStatus represents the current state of registry synchronization

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL