cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache stores a local cache of marshaled repos (only small repos will be cached because we're limited on memory). There should be one Cache per server. All methods should be safe for concurrent execution.

func New

func New(database services.Database, fetcher services.Fetcher, resolver services.Resolver, configHintsKind string) *Cache

New returns a new cache.

func (*Cache) NewRequest

func (c *Cache) NewRequest(save bool) *Request

New returns a new request. Any packages that we know will be requested during the request can be specified with hints, and the request will try pre-fetch in parallel all the repos that we need to fulfill this request (using a database of previously encountered package->dependencies). If the dependencies have recently changed this will be picked up during the "go get" execution and the correct dependencies will be requested (this will ensure correct execution).

func (*Cache) ResolveHints

func (c *Cache) ResolveHints(ctx context.Context, hints []string) (resolved []string, err error)

func (*Cache) SaveHints

func (c *Cache) SaveHints(ctx context.Context, resolved map[string][]string) error

type CallGroup

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

Group represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.

func (*CallGroup) Do

func (g *CallGroup) Do(ctx context.Context, url string, fn func(ctx context.Context, url string) (billy.Filesystem, error)) (billy.Filesystem, error)

Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.

type Hints

type Hints struct {
	Path  string
	Hints []string
}

type Request

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

Request represents a single request, possibly with several "go get" operations. It is assumed that all "git fetch" operations that happen in one request are current for the entire request.

func (*Request) Close

func (r *Request) Close(ctx context.Context) error

Close should be called once all getters have finished, and saves the hints back to the HintResolver.

func (*Request) Fetch

func (r *Request) Fetch(ctx context.Context, url string) (billy.Filesystem, error)

Fetch does either a git clone or a git fetch to ensure we have the latest version of the repo and returns the work tree. If a request for this repo is already in flight (e.g. from the init method), we wait for that one to finish instead of starting a new one.

func (*Request) InitialiseFromHints

func (r *Request) InitialiseFromHints(ctx context.Context, paths ...string) error

Hint looks up hints in the database to get a best guess list of repos, then starts to fetch all of them in parallel TODO: use a worker pool

func (*Request) Resolver

func (r *Request) Resolver() services.Resolver

func (*Request) SetHints

func (r *Request) SetHints(hints map[string][]string)

Stores hints

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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