stash

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisLogger added in v0.12.0

type RedisLogger interface {
	Printf(ctx context.Context, format string, v ...any)
}

RedisLogger mirrors github.com/go-redis/redis/v8/internal.Logging.

type Stasher

type Stasher interface {
	Stash(ctx context.Context, mod, ver string) (string, error)
}

Stasher has the job of taking a module from an upstream entity and stashing it to a Storage Backend and Index. It also returns a string that represents a semver version of what was requested, this is helpful if what was requested was a descriptive version such as a branch name or a full commit sha.

func New

func New(f module.Fetcher, s storage.Backend, indexer index.Indexer, wrappers ...Wrapper) Stasher

New returns a plain stasher that takes a module from a download.Protocol and stashes it into a backend.Storage.

func WithGCSLock added in v0.4.0

func WithGCSLock(s Stasher) Stasher

WithGCSLock returns a distributed singleflight using a GCS backend. See the config.toml documentation for details.

func WithSingleflight

func WithSingleflight(s Stasher) Stasher

WithSingleflight returns a singleflight stasher. This two clients make two subsequent requests to stash a module, then it will only do it once and give the first response to both the first and the second client.

type Wrapper

type Wrapper func(Stasher) Stasher

Wrapper helps extend the main stasher's functionality with addons.

func WithAzureBlobLock added in v0.4.0

func WithAzureBlobLock(conf *config.AzureBlobConfig, timeout time.Duration, checker storage.Checker) (Wrapper, error)

WithAzureBlobLock returns a distributed singleflight using a Azure Blob Storage backend. See the config.toml documentation for details.

func WithEtcd added in v0.3.0

func WithEtcd(endpoints []string, checker storage.Checker) (Wrapper, error)

WithEtcd returns a distributed singleflight using an etcd cluster. If it cannot connect, to any of the endpoints, it will return an error.

func WithPool

func WithPool(numWorkers int) Wrapper

WithPool returns a stasher that runs a stash operation {numWorkers} at a time.

func WithRedisLock added in v0.4.0

func WithRedisLock(l RedisLogger, endpoint, password string, checker storage.Checker, lockConfig *config.RedisLockConfig) (Wrapper, error)

WithRedisLock returns a distributed singleflight using a redis cluster. If it cannot connect, it will return an error.

func WithRedisSentinelLock added in v0.8.0

func WithRedisSentinelLock(l RedisLogger, endpoints []string, master, password string, checker storage.Checker, lockConfig *config.RedisLockConfig) (Wrapper, error)

WithRedisSentinelLock returns a distributed singleflight with a redis cluster that utilizes sentinel for quorum and failover.

Jump to

Keyboard shortcuts

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