cache

package
v0.0.0-...-81c6e22 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvictOnConnectionFailure

func EvictOnConnectionFailure(dialer proxy.Dialer, frequency time.Duration) func(*RemoteSnapshotterCache)

EvictOnConnectionFailure is a caching option for evicting entries from the cache after a failed connection attempt.

Types

type EvictOnConnectionFailurePolicy

type EvictOnConnectionFailurePolicy struct {
	// contains filtered or unexported fields
}

EvictOnConnectionFailurePolicy defines an eviction policy where entries are evicted from cache after a failed connection attempt occurs.

func (EvictOnConnectionFailurePolicy) Enforce

func (p EvictOnConnectionFailurePolicy) Enforce(key string)

Enforce launches a go routine which periodically attempts to dial the cached entry using the provided dial function.

On connection failure, the entry will be evicted from cache.

type EvictionPolicy

type EvictionPolicy interface {
	// Enforce monitors for policy failures.
	Enforce(key string)
}

EvictionPolicy defines the interface for enforcing a cache eviction policy.

func NewEvictOnConnectionFailurePolicy

func NewEvictOnConnectionFailurePolicy(evictChan chan string, dialer proxy.Dialer, frequency time.Duration, stopCondition chan struct{}) EvictionPolicy

NewEvictOnConnectionFailurePolicy creates a new policy to evict on remote snapshotter connection failure on a specified frequency duration.

type RemoteSnapshotterCache

type RemoteSnapshotterCache struct {
	// contains filtered or unexported fields
}

RemoteSnapshotterCache implements a cache for remote snapshotters.

func NewRemoteSnapshotterCache

func NewRemoteSnapshotterCache(fetch SnapshotterProvider, opts ...SnapshotterCacheOption) *RemoteSnapshotterCache

NewRemoteSnapshotterCache creates a new instance with an empty cache and applies any provided caching options.

func (*RemoteSnapshotterCache) Close

func (c *RemoteSnapshotterCache) Close() error

Close terminates any background reapers and closes any cached snapshotters.

func (*RemoteSnapshotterCache) Evict

func (c *RemoteSnapshotterCache) Evict(key string) error

Evict removes a cached snapshotter for a given key.

func (*RemoteSnapshotterCache) Get

Get fetches and caches the snapshotter for a given key.

func (*RemoteSnapshotterCache) List

func (c *RemoteSnapshotterCache) List() []string

List returns the keys of a snapshotter cache.

func (*RemoteSnapshotterCache) WalkAll

func (c *RemoteSnapshotterCache) WalkAll(ctx context.Context, fn snapshots.WalkFunc, filters ...string) error

WalkAll applies the provided function to all cached snapshotters.

type SnapshotterCacheOption

type SnapshotterCacheOption func(*RemoteSnapshotterCache)

SnapshotterCacheOption is a functional option that operates on a remote snapshotter cache.

type SnapshotterProvider

type SnapshotterProvider = func(context.Context, string) (*proxy.RemoteSnapshotter, error)

SnapshotterProvider defines a snapshotter fetch function.

Jump to

Keyboard shortcuts

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