v0.17.0 Latest Latest

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 22 Imported by: 13



Package manifest implements support for managing JSON-based manifests in repository.



View Source
const (
	ContentPrefix = "m"

ContentPrefix is the prefix of the content id for manifests.

View Source
const TypeLabelKey = "type"

TypeLabelKey is the label key for manifest type.


View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the metadata item is not found.


func IDsToStrings added in v0.14.0

func IDsToStrings(input []ID) []string

IDsToStrings converts the IDs to strings.


type EntryMetadata

type EntryMetadata struct {
	ID      ID                `json:"id"`
	Length  int               `json:"length"`
	Labels  map[string]string `json:"labels"`
	ModTime time.Time         `json:"mtime"`

EntryMetadata contains metadata about manifest item. Each manifest item has one or more labels Including required "type" label.

func DedupeEntryMetadataByLabel added in v0.8.0

func DedupeEntryMetadataByLabel(entries []*EntryMetadata, label string) []*EntryMetadata

DedupeEntryMetadataByLabel deduplicates EntryMetadata in a provided slice by picking the latest one for a given set of label.

type ID

type ID string

ID is a unique identifier of a single manifest.

func IDsFromStrings added in v0.14.0

func IDsFromStrings(input []string) []ID

IDsFromStrings converts the IDs to strings.

func PickLatestID added in v0.8.0

func PickLatestID(entries []*EntryMetadata) ID

PickLatestID picks the ID of latest EntryMetadata in a given slice.

type Manager

type Manager struct {
	// contains filtered or unexported fields

Manager organizes JSON manifests of various kinds, including snapshot manifests.

func NewManager

func NewManager(ctx context.Context, b contentManager, options ManagerOptions, mr *metrics.Registry) (*Manager, error)

NewManager returns new manifest manager for the provided content manager.

func (*Manager) Compact

func (m *Manager) Compact(ctx context.Context) error

Compact performs compaction of manifest contents.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id ID) error

Delete marks the specified manifest ID for deletion.

func (*Manager) Find

func (m *Manager) Find(ctx context.Context, labels map[string]string) ([]*EntryMetadata, error)

Find returns the list of EntryMetadata for manifest entries matching all provided labels.

func (*Manager) Flush

func (m *Manager) Flush(ctx context.Context) error

Flush persists changes to manifest manager.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, id ID, data interface{}) (*EntryMetadata, error)

Get retrieves the contents of the provided manifest item by deserializing it as JSON to provided object. If the manifest is not found, returns ErrNotFound.

func (*Manager) GetMetadata

func (m *Manager) GetMetadata(ctx context.Context, id ID) (*EntryMetadata, error)

GetMetadata returns metadata about provided manifest item or ErrNotFound if the item can't be found.

func (*Manager) Put

func (m *Manager) Put(ctx context.Context, labels map[string]string, payload interface{}) (ID, error)

Put serializes the provided payload to JSON and persists it. Returns unique identifier that represents the manifest.

type ManagerOptions added in v0.6.0

type ManagerOptions struct {
	TimeNow                 func() time.Time // Time provider
	AutoCompactionThreshold int

ManagerOptions are optional parameters for Manager creation.

Jump to

Keyboard shortcuts

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