Documentation ¶
Overview ¶
Package maintenance manages automatic repository maintenance.
Index ¶
- func DeleteUnreferencedBlobs(ctx context.Context, rep MaintainableRepository, ...) (int, error)
- func DropDeletedContents(ctx context.Context, rep MaintainableRepository, dropDeletedBefore time.Time) error
- func HasParams(ctx context.Context, rep MaintainableRepository) (bool, error)
- func IndexCompaction(ctx context.Context, rep MaintainableRepository) error
- func ReportRun(ctx context.Context, rep MaintainableRepository, runType string, ...) error
- func RewriteContents(ctx context.Context, rep MaintainableRepository, opt *RewriteContentsOptions) error
- func Run(ctx context.Context, runParams RunParameters) error
- func RunExclusive(ctx context.Context, rep MaintainableRepository, mode Mode, force bool, ...) error
- func SetParams(ctx context.Context, rep MaintainableRepository, par *Params) error
- func SetSchedule(ctx context.Context, rep MaintainableRepository, s *Schedule) error
- type CycleParams
- type DeleteUnreferencedBlobsOptions
- type MaintainableRepository
- type Mode
- type NotOwnedError
- type Params
- type RewriteContentsOptions
- type RunInfo
- type RunParameters
- type Schedule
- type SnapshotGCParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteUnreferencedBlobs ¶
func DeleteUnreferencedBlobs(ctx context.Context, rep MaintainableRepository, opt DeleteUnreferencedBlobsOptions) (int, error)
DeleteUnreferencedBlobs deletes old blobs that are no longer referenced by index entries.
func DropDeletedContents ¶
func DropDeletedContents(ctx context.Context, rep MaintainableRepository, dropDeletedBefore time.Time) error
DropDeletedContents rewrites indexes while dropping deleted contents above certain age.
func HasParams ¶
func HasParams(ctx context.Context, rep MaintainableRepository) (bool, error)
HasParams determines whether repository-wide maintenance parameters have been set.
func IndexCompaction ¶
func IndexCompaction(ctx context.Context, rep MaintainableRepository) error
IndexCompaction rewrites index blobs to reduce their count but does not drop any contents.
func ReportRun ¶
func ReportRun(ctx context.Context, rep MaintainableRepository, runType string, run func() error) error
ReportRun reports timing of a maintenance run and persists it in repository.
func RewriteContents ¶
func RewriteContents(ctx context.Context, rep MaintainableRepository, opt *RewriteContentsOptions) error
RewriteContents rewrites contents according to provided criteria and creates new blobs and index entries to point at the
func Run ¶
func Run(ctx context.Context, runParams RunParameters) error
Run performs maintenance activities for a repository.
func RunExclusive ¶
func RunExclusive(ctx context.Context, rep MaintainableRepository, mode Mode, force bool, cb func(runParams RunParameters) error) error
RunExclusive runs the provided callback if the maintenance is owned by local user and lock can be acquired. Lock is passed to the function, which ensures that every call to Run() is within the exclusive context.
func SetParams ¶
func SetParams(ctx context.Context, rep MaintainableRepository, par *Params) error
SetParams sets the maintenance parameters.
func SetSchedule ¶
func SetSchedule(ctx context.Context, rep MaintainableRepository, s *Schedule) error
SetSchedule updates scheduled maintenance times.
Types ¶
type CycleParams ¶
CycleParams specifies parameters for a maintenance cycle (quick or full).
type DeleteUnreferencedBlobsOptions ¶
type DeleteUnreferencedBlobsOptions struct { Parallel int Prefix blob.ID MinAge time.Duration DryRun bool }
DeleteUnreferencedBlobsOptions provides option for blob garbage collection algorithm.
type MaintainableRepository ¶
type MaintainableRepository interface { Username() string Hostname() string Time() time.Time ConfigFilename() string BlobStorage() blob.Storage ContentManager() *content.Manager GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) DeleteManifest(ctx context.Context, id manifest.ID) error DeriveKey(purpose []byte, keyLength int) []byte }
MaintainableRepository is a subset of Repository required for maintenance tasks.
type NotOwnedError ¶
type NotOwnedError struct {
Owner string
}
NotOwnedError is returned when maintenance cannot run because it is owned by another user.
func (NotOwnedError) Error ¶
func (e NotOwnedError) Error() string
type Params ¶
type Params struct { Owner string `json:"owner"` QuickCycle CycleParams `json:"quick"` FullCycle CycleParams `json:"full"` SnapshotGC SnapshotGCParams `json:"snapshotGC"` }
Params is a JSON-serialized maintenance configuration stored in a repository.
func DefaultParams ¶
func DefaultParams() Params
DefaultParams represents default values of maintenance parameters.
type RewriteContentsOptions ¶
type RewriteContentsOptions struct { Parallel int MinAge time.Duration ContentIDs []content.ID ContentIDRange content.IDRange PackPrefix blob.ID ShortPacks bool FormatVersion int DryRun bool }
RewriteContentsOptions provides options for RewriteContents
type RunInfo ¶
type RunInfo struct { Start time.Time `json:"start"` End time.Time `json:"end"` Success bool `json:"success,omitempty"` Error string `json:"error,omitempty"` }
RunInfo represents information about a single run of a maintenance task.
type RunParameters ¶
RunParameters passes essential parameters for maintenance. It is generated by RunExclusive and can't be create outside of its package and is required to ensure all maintenance tasks run under an exclusive lock.
type Schedule ¶
type Schedule struct { NextFullMaintenanceTime time.Time `json:"nextFullMaintenance"` NextQuickMaintenanceTime time.Time `json:"nextQuickMaintenance"` Runs map[string][]RunInfo `json:"runs"` }
Schedule keeps track of scheduled maintenance times.
func GetSchedule ¶
func GetSchedule(ctx context.Context, rep MaintainableRepository) (*Schedule, error)
GetSchedule gets the scheduled maintenance times.
type SnapshotGCParams ¶
SnapshotGCParams contains parameters for Snapshot Garbage Collection NOTE: Due to layering, the implementation of Snapshot GC is outside of repository package but for simplicity we store it here.