flux: github.com/weaveworks/flux/pkg/registry/cache Index | Files | Directories

package cache

import "github.com/weaveworks/flux/pkg/registry/cache"

This package implements an image metadata cache given a backing k-v store.

The interface `Client` stands in for the k-v store (e.g., memcached, in the subpackage); `Cache` implements registry.Registry given a `Client`.

The `Warmer` is for continually refreshing the cache by fetching new metadata from the original image registries.

Index

Package Files

cache.go doc.go monitoring.go registry.go repocachemanager.go warming.go

Variables

var (
    ErrNotCached = &fluxerr.Error{
        Type: fluxerr.Missing,
        Err:  errors.New("item not in cache"),
        Help: "" /* 238 byte string literal not displayed */,
    }
)

type Cache Uses

type Cache struct {
    Reader     Reader
    Decorators []Decorator
}

Cache is a local cache of image metadata.

func (*Cache) GetImage Uses

func (c *Cache) GetImage(id image.Ref) (image.Info, error)

GetImage gets the manifest of a specific image ref, from its registry.

func (*Cache) GetImageRepositoryMetadata Uses

func (c *Cache) GetImageRepositoryMetadata(id image.Name) (image.RepositoryMetadata, error)

GetImageRepositoryMetadata returns the metadata from an image repository (e.g,. at "docker.io/fluxcd/flux")

type Client Uses

type Client interface {
    Reader
    Writer
}

func InstrumentClient Uses

func InstrumentClient(c Client) Client

type Decorator Uses

type Decorator interface {
    // contains filtered or unexported methods
}

Decorator is for decorating an ImageRepository before it is returned.

type ImageRepository Uses

type ImageRepository struct {
    image.RepositoryMetadata
    LastError  string
    LastUpdate time.Time
}

ImageRepository holds the last good information on an image repository.

Whenever we successfully fetch a set (partial or full) of image metadata, `LastUpdate`, `Tags` and `Images` shall each be assigned a value, and `LastError` will be cleared.

If we cannot for any reason obtain the set of image metadata, `LastError` shall be assigned a value, and the other fields left alone.

It's possible to have all fields populated: this means at some point it was successfully fetched, but since then, there's been an error. It's then up to the caller to decide what to do with the value (show the images, but also indicate there's a problem, for example).

type Keyer Uses

type Keyer interface {
    Key() string
}

An interface to provide the key under which to store the data Use the full path to image for the memcache key because there might be duplicates from other registries

func NewManifestKey Uses

func NewManifestKey(image image.CanonicalRef) Keyer

func NewRepositoryKey Uses

func NewRepositoryKey(repo image.CanonicalName) Keyer

type Reader Uses

type Reader interface {
    // GetKey gets the value at a key, along with its refresh deadline
    GetKey(k Keyer) ([]byte, time.Time, error)
}

type StringSet Uses

type StringSet map[string]struct{}

StringSet is a set of strings.

func NewStringSet Uses

func NewStringSet(ss []string) StringSet

NewStringSet returns a StringSet containing exactly the strings given as arguments.

func (StringSet) Subset Uses

func (s StringSet) Subset(t StringSet) bool

Subset returns true if `s` is a subset of `t` (including the case of having the same members).

type TimestampLabelWhitelist Uses

type TimestampLabelWhitelist []string

TimestampLabelWhitelist contains a string slice of glob patterns. Any canonical image reference that matches one of the glob patterns will prefer creation timestamps from labels over the one it received from the registry.

type Warmer Uses

type Warmer struct {
    Trace    bool
    Priority chan image.Name
    Notify   func()
    // contains filtered or unexported fields
}

Warmer refreshes the information kept in the cache from remote registries.

func NewWarmer Uses

func NewWarmer(cf registry.ClientFactory, cacheClient Client, burst int) (*Warmer, error)

NewWarmer creates cache warmer that (when Loop is invoked) will periodically refresh the values kept in the cache.

func (*Warmer) Loop Uses

func (w *Warmer) Loop(logger log.Logger, stop <-chan struct{}, wg *sync.WaitGroup, imagesToFetchFunc func() registry.ImageCreds)

Loop continuously gets the images to populate the cache with, and populate the cache with them.

type Writer Uses

type Writer interface {
    // SetKey sets the value at a key, along with its refresh deadline
    SetKey(k Keyer, deadline time.Time, v []byte) error
}

Directories

PathSynopsis
memcachedThis package implements an image DB cache using memcached.

Package cache imports 16 packages (graph). Updated 2020-08-28. Refresh now. Tools for package owners.