Documentation ¶
Index ¶
- type Cache
- type CallGroup
- type Hints
- type Request
- func (r *Request) Close(ctx context.Context) error
- func (r *Request) Fetch(ctx context.Context, url string) (billy.Filesystem, error)
- func (r *Request) InitialiseFromHints(ctx context.Context, paths ...string) error
- func (r *Request) Resolver() services.Resolver
- func (r *Request) SetHints(hints map[string][]string)
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 ¶
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 ¶
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 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 ¶
Close should be called once all getters have finished, and saves the hints back to the HintResolver.
func (*Request) Fetch ¶
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 ¶
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