stash

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stasher

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

Stasher has the job of taking a module from an upstream entity and stashing it to a Storage Backend. 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, wrappers ...Wrapper) Stasher

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

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 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.

Jump to

Keyboard shortcuts

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