store

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailedFileRecord

type FailedFileRecord struct {
	ID               int64
	Provider         string
	FilePath         string
	URL              string
	DestPath         string // absolute local filesystem path for downloads
	ExpectedChecksum string
	ExpectedSize     int64
	Error            string
	RetryCount       int
	FirstFailure     time.Time
	LastFailure      time.Time
	Resolved         bool
}

FailedFileRecord is a dead letter queue entry

type FileRecord

type FileRecord struct {
	ID           int64
	Provider     string
	Path         string // relative to provider output dir
	Size         int64
	SHA256       string
	LastModified time.Time
	LastVerified time.Time
	SyncRunID    int64
}

FileRecord tracks a downloaded file

type Job

type Job struct {
	ID        int64
	Type      string // "sync", "validate", "export", "import"
	Provider  string // empty for "all providers" jobs
	CronExpr  string // for scheduled jobs
	Status    string // "scheduled", "running", "completed", "failed"
	LastRun   time.Time
	NextRun   time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

Job represents a scheduled or completed job

type ProviderConfig

type ProviderConfig struct {
	ID         int64
	Name       string
	Type       string // "epel", "ocp_binaries", "ocp_clients", "rhcos", "container_images", "registry", "custom_files"
	Enabled    bool
	ConfigJSON string
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

ProviderConfig stores a provider's configuration in the database.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store provides SQLite-backed persistence

func New

func New(dbPath string, logger *slog.Logger) (*Store, error)

New creates a new Store, opening the SQLite database and running migrations

func (*Store) AddFailedFile

func (s *Store) AddFailedFile(rec *FailedFileRecord) error

AddFailedFile adds a new FailedFileRecord

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) CountFileRecords

func (s *Store) CountFileRecords(provider string) (int, error)

CountFileRecords returns the count of FileRecords for a provider

func (*Store) CountProviderConfigs

func (s *Store) CountProviderConfigs() (int, error)

CountProviderConfigs returns the number of provider configs.

func (*Store) CreateJob

func (s *Store) CreateJob(job *Job) error

CreateJob inserts a new Job and sets its ID

func (*Store) CreateProviderConfig

func (s *Store) CreateProviderConfig(pc *ProviderConfig) error

CreateProviderConfig inserts a new ProviderConfig and sets its ID.

func (*Store) CreateSyncRun

func (s *Store) CreateSyncRun(run *SyncRun) error

CreateSyncRun inserts a new SyncRun and sets its ID

func (*Store) CreateTransfer

func (s *Store) CreateTransfer(t *Transfer) error

CreateTransfer inserts a new Transfer and sets its ID

func (*Store) CreateTransferArchive

func (s *Store) CreateTransferArchive(a *TransferArchive) error

CreateTransferArchive inserts a new TransferArchive and sets its ID

func (*Store) DeleteFileRecord

func (s *Store) DeleteFileRecord(provider, path string) error

DeleteFileRecord deletes a FileRecord by provider and path

func (*Store) DeleteProviderConfig

func (s *Store) DeleteProviderConfig(name string) error

DeleteProviderConfig deletes a ProviderConfig by name.

func (*Store) GetFileRecord

func (s *Store) GetFileRecord(provider, path string) (*FileRecord, error)

GetFileRecord retrieves a FileRecord by provider and path

func (*Store) GetProviderConfig

func (s *Store) GetProviderConfig(name string) (*ProviderConfig, error)

GetProviderConfig retrieves a ProviderConfig by name.

func (*Store) GetSyncRun

func (s *Store) GetSyncRun(id int64) (*SyncRun, error)

GetSyncRun retrieves a SyncRun by ID

func (*Store) IncrementFailedRetry

func (s *Store) IncrementFailedRetry(id int64) error

IncrementFailedRetry increments the retry count and updates last_failure

func (*Store) IsArchiveValidated

func (s *Store) IsArchiveValidated(path, archiveName, sha256 string) (bool, error)

IsArchiveValidated checks whether an archive with the given path, name, and sha256 has been previously validated in a completed transfer.

func (*Store) ListFailedFiles

func (s *Store) ListFailedFiles(provider string) ([]FailedFileRecord, error)

ListFailedFiles retrieves all FailedFileRecords for a provider

func (*Store) ListFileRecords

func (s *Store) ListFileRecords(provider string) ([]FileRecord, error)

ListFileRecords retrieves all FileRecords for a provider

func (*Store) ListJobs

func (s *Store) ListJobs(status string, limit int) ([]Job, error)

ListJobs retrieves Jobs, optionally filtered by status

func (*Store) ListProviderConfigs

func (s *Store) ListProviderConfigs() ([]ProviderConfig, error)

ListProviderConfigs retrieves all ProviderConfigs ordered by name.

func (*Store) ListSyncRuns

func (s *Store) ListSyncRuns(provider string, limit int) ([]SyncRun, error)

ListSyncRuns retrieves SyncRuns, optionally filtered by provider

func (*Store) ListTransferArchives

func (s *Store) ListTransferArchives(transferID int64) ([]TransferArchive, error)

ListTransferArchives retrieves all archives for a transfer

func (*Store) ListTransfers

func (s *Store) ListTransfers(limit int) ([]Transfer, error)

ListTransfers retrieves Transfers, optionally limited

func (*Store) MarkArchiveValidated

func (s *Store) MarkArchiveValidated(id int64) error

MarkArchiveValidated marks a TransferArchive as validated

func (*Store) ResolveFailedFile

func (s *Store) ResolveFailedFile(id int64) error

ResolveFailedFile marks a FailedFileRecord as resolved

func (*Store) SeedProviderConfigs

func (s *Store) SeedProviderConfigs(yamlProviders map[string]map[string]interface{}) error

SeedProviderConfigs populates provider_configs from a YAML providers map. This is a no-op if the table already has rows.

func (*Store) SumFileSize

func (s *Store) SumFileSize(provider string) (int64, error)

SumFileSize returns the total size of all files for a provider

func (*Store) ToggleProviderConfig

func (s *Store) ToggleProviderConfig(name string) error

ToggleProviderConfig flips the enabled state of a provider.

func (*Store) UpdateJob

func (s *Store) UpdateJob(job *Job) error

UpdateJob updates an existing Job by ID

func (*Store) UpdateProviderConfig

func (s *Store) UpdateProviderConfig(pc *ProviderConfig) error

UpdateProviderConfig updates an existing ProviderConfig by ID.

func (*Store) UpdateSyncRun

func (s *Store) UpdateSyncRun(run *SyncRun) error

UpdateSyncRun updates an existing SyncRun by ID

func (*Store) UpdateTransfer

func (s *Store) UpdateTransfer(t *Transfer) error

UpdateTransfer updates an existing Transfer by ID

func (*Store) UpsertFileRecord

func (s *Store) UpsertFileRecord(rec *FileRecord) error

UpsertFileRecord inserts or replaces a FileRecord

type SyncRun

type SyncRun struct {
	ID               int64
	Provider         string
	StartTime        time.Time
	EndTime          time.Time
	FilesDownloaded  int
	FilesDeleted     int
	FilesSkipped     int
	FilesFailed      int
	BytesTransferred int64
	Status           string // "success", "partial", "failed"
	ErrorMessage     string
}

SyncRun records a sync execution

type Transfer

type Transfer struct {
	ID           int64
	Direction    string // "export" or "import"
	Path         string // source/destination path
	Providers    string // comma-separated provider names
	ArchiveCount int
	TotalSize    int64
	ManifestHash string
	Status       string // "running", "completed", "failed"
	ErrorMessage string
	StartTime    time.Time
	EndTime      time.Time
}

Transfer records an export or import operation

type TransferArchive

type TransferArchive struct {
	ID          int64
	TransferID  int64
	ArchiveName string
	SHA256      string
	Size        int64
	Validated   bool
	ValidatedAt time.Time
}

TransferArchive tracks per-archive validation state during import

Jump to

Keyboard shortcuts

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