assoc

package
v0.0.0-...-90deddd Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package assoc defines data types for associative maps used within Reflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assoc

type Assoc interface {
	// Store unconditionally stores the association k, v.
	// Zero values indicate that the association is to be deleted.
	Store(ctx context.Context, kind Kind, k, v digest.Digest) error

	// Get returns the digest associated with key digest k and the
	// provided kind. Get returns an errors.NotExist when no such
	// mapping exists. Get expands the provided key when it is abbreviated,
	// and returns the expanded key when appropriate.
	Get(ctx context.Context, kind Kind, k digest.Digest) (kexp, v digest.Digest, err error)

	// BatchGet fetches a batch of keys. The result or error is set for each key.
	// Global errors (such as context errors or unrecoverable system errors)
	// are returned. Errors that can be attributable to a single fetch is returned
	// as that key's error.
	BatchGet(ctx context.Context, batch Batch) error

	// CollectWithThreshold removes from this assoc any objects whose keys are not in the
	// liveset and is either in the dead set or its creation times are not more recent than the threshold time.
	CollectWithThreshold(ctx context.Context, live, dead liveset.Liveset, threshold time.Time, rate int64, dryrun bool) error

	// Count returns an estimate of the number of associations in this mapping.
	Count(ctx context.Context) (int64, error)

	// Scan calls the handler function for every association in the mapping.
	// Note that the handler function may be called asynchronously from multiple threads.
	Scan(ctx context.Context, kinds []Kind, handler MappingHandler) error

	// Delete deletes the key k unconditionally from the provided assoc.
	Delete(ctx context.Context, k digest.Digest) error
}

An Assoc is an associative array mapping digests to other digests. Mappings are also assigned a kind, and can thus be expanded to store multiple types of mapping for each key.

type Batch

type Batch map[Key]Result

Batch is map of keys, fetched together.

func (Batch) Add

func (b Batch) Add(keys ...Key)

Add adds a key to the set if it doesn't exist already.

func (Batch) Found

func (b Batch) Found(key Key) bool

Found returns if the key is present in the result set.

type Key

type Key struct {
	// Kind is the mapping kind.
	Kind
	// Digest is the key digest.
	digest.Digest
}

Key is the (key, kind) pair which uniquely identifies a value in the assoc.

func (Key) String

func (k Key) String() string

String returns the key (digest, kind) as a string.

type Kind

type Kind int

Kind describes the kind of mapping.

const (
	// Fileset maps fileset values. See the fileset.marshalJSON
	// docstring for more information about the format.
	Fileset Kind = iota
	// FilesetV2 maps fileset v2 values. See the fileset.marshalProto
	// docstring for more information about the format.
	FilesetV2
)

func (Kind) String

func (i Kind) String() string

type MappingHandler

type MappingHandler interface {
	// HandleMapping handles a scanned association.
	HandleMapping(ctx context.Context, k digest.Digest, v map[Kind]digest.Digest, lastAccessTime time.Time, labels []string)
}

MappingHandler is an interface for handling a mapping while scanning.

type MappingHandlerFunc

type MappingHandlerFunc func(k digest.Digest, v map[Kind]digest.Digest, lastAccessTime time.Time, labels []string)

MappingHandlerFunc is a convenience type to avoid having to declare a struct to implement the MappingHandler interface.

func (MappingHandlerFunc) HandleMapping

func (h MappingHandlerFunc) HandleMapping(_ context.Context, k digest.Digest, v map[Kind]digest.Digest, lastAccessTime time.Time, labels []string)

HandleMapping implements the MappingHandler interface.

type Result

type Result struct {
	// Digest is the result of a lookup.
	digest.Digest
	// Err is the error during lookup, if any.
	Error error
}

Result is set of a key, kind and its value.

Directories

Path Synopsis
Package dydbassoc implements an assoc.Assoc based on AWS's DynamoDB.
Package dydbassoc implements an assoc.Assoc based on AWS's DynamoDB.

Jump to

Keyboard shortcuts

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