Documentation
¶
Overview ¶
Package warm serves the tree of a check from a local bare clone of the repository. It keeps one bare clone per repository, updates it when a Watcher reports a ref change, and keeps a few ready checkouts that it moves to the requested commit. A checkout holds plain files and no .git, so a check cannot write into the shared clone.
Index ¶
- Constants
- func CheckGitVersion(out string) error
- type Config
- type Fetcher
- func (f *Fetcher) Changed(repo string)
- func (f *Fetcher) Close()
- func (f *Fetcher) Fetch(ctx context.Context, req runnerproto.Request, dir string) error
- func (f *Fetcher) Repos() []string
- func (f *Fetcher) Run(ctx context.Context, ws ...Watcher)
- func (f *Fetcher) Sweep()
- func (f *Fetcher) Sync(ctx context.Context, name string)
- func (f *Fetcher) Wait()
- type Watcher
Constants ¶
const MinGit = "2.31"
MinGit is the oldest git that the warm path runs: the environment variables GIT_CONFIG_COUNT, GIT_CONFIG_KEY_n and GIT_CONFIG_VALUE_n, which carry the credential header, need git 2.31.
Variables ¶
This section is empty.
Functions ¶
func CheckGitVersion ¶
CheckGitVersion fails when the output of git --version names a git older than MinGit.
Types ¶
type Config ¶
type Config struct {
// Dir holds the bare clones. It lives across restarts.
Dir string
// PoolDir holds the ready checkouts. It must be on the file system of the check directories, so that a handout is a
// rename. The fetcher empties it at start.
PoolDir string
// Remote returns the git URL of repo.
Remote func(repo string) (string, error)
// Header returns a complete HTTP header line that authenticates a git request. Empty or nil means none.
Header func(ctx context.Context) (string, error)
// Fallback gets the tree when the warm path fails for a reason other than a refusal. Nil means the failure stands.
Fallback func(ctx context.Context, req runnerproto.Request, dir string) error
// PoolSize is the ready checkouts for each repository. Default 2.
PoolSize int
// MaxRepos and MaxBytes bound the cache. The fetcher removes the clone that was used least recently and is idle.
// Defaults 16 and 20 GiB.
MaxRepos int
MaxBytes int64
Clock check.Clock
Log *slog.Logger
}
Config says where the caches live and how large they grow. Dir, PoolDir and Remote are required.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher serves trees from the warm cache. Fetch has the signature of runner.Options.Fetch.
func New ¶
New makes a fetcher. It starts no background work until a request or a sync needs it. Close stops that work.
func (*Fetcher) Changed ¶
Changed syncs the clone of repo in the background. An empty repo syncs every clone.
func (*Fetcher) Close ¶
func (f *Fetcher) Close()
Close cancels the background work, refuses new work and waits for the work that is under way. It is safe to call twice.
func (*Fetcher) Fetch ¶
Fetch writes the files of req.Tree to the empty directory dir. It refuses a commit whose tree is another tree and a tree that holds a submodule. A failure of the cache makes one new clone and a second try, and then runs the fallback.
func (*Fetcher) Run ¶
Run starts each watcher and syncs the clone of each reported repository. It returns when ctx ends. A sweep runs every ten minutes.
func (*Fetcher) Sweep ¶
func (f *Fetcher) Sweep()
Sweep removes idle clones, least recently used first, until the cache fits MaxBytes.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package motteevents is a warm.Watcher that polls the ref events of motte.
|
Package motteevents is a warm.Watcher that polls the ref events of motte. |
|
Package periodic is the fallback warm.Watcher: it reports every known repository as changed at a fixed interval.
|
Package periodic is the fallback warm.Watcher: it reports every known repository as changed at a fixed interval. |
|
Package warmtest is the conformance suite of warm.Watcher.
|
Package warmtest is the conformance suite of warm.Watcher. |