cached

package
v0.0.0-...-b9f4276 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package cached handles a metadata.Provider implementation that both downloads and caches the MDS3 blob. This effectively is the recommended provider in most instances as it's fairly robust. Alternatively we suggest implementing a similar provider that leverages the memory.Provider as an underlying element.

This provider only specifically performs updates at the time it's initialized. It has no automatic update functionality. This may change in the future however if you want this functionality at this time we recommend making your own implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) (provider metadata.Provider, err error)

New returns a new cached Provider given a set of functional Option's. This provider will download a new version and save it to the configured file path if it doesn't exist or if it's out of date by default.

Types

type NewFunc

type NewFunc func(mds *metadata.Metadata) (provider metadata.Provider, err error)

NewFunc describes the type used to create the underlying provider.

type Option

type Option func(provider *Provider) (err error)

Option describes an optional pattern for this provider.

func WithClient

func WithClient(client *http.Client) Option

WithClient configures the *http.Client used to get the MDS3 blob.

func WithClock

func WithClock(clock metadata.Clock) Option

WithClock allows injection of a metadata.Clock to check the up-to-date status of a blob.

func WithDecoder

func WithDecoder(decoder *metadata.Decoder) Option

WithDecoder sets the decoder to be used for this provider. By default this is a decoder with the entry parsing errors configured to skip that entry.

func WithForceUpdate

func WithForceUpdate(force bool) Option

WithForceUpdate is used to force an update on creation. This will forcibly overwrite the file if possible.

func WithMetadataURL

func WithMetadataURL(uri string) Option

WithMetadataURL configures the URL to get the metadata from. This shouldn't be modified unless you know what you're doing as we use the metadata.ProductionMDSURL which is safe in most instances.

func WithNew

func WithNew(newup NewFunc) Option

WithNew customizes the NewFunc. By default we just create a fairly standard memory.Provider with strict defaults.

func WithPath

func WithPath(name string) Option

WithPath sets the path name for the cached file. This option is REQUIRED.

func WithUpdate

func WithUpdate(update bool) Option

WithUpdate is used to enable or disable the update. By default it's set to true.

type Provider

type Provider struct {
	metadata.Provider
	// contains filtered or unexported fields
}

Provider implements a metadata.Provider with a file-based cache.

Jump to

Keyboard shortcuts

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