Documentation
¶
Overview ¶
Package template keeps the templates copy-on-write workspaces are made from: one read-only checkout of a repository at a commit, built once and shared by every workspace of that commit, and retired once none uses it.
A template is what a workspace is today — a checkout whose `.git` borrows from the pool — and it never changes once built: a layer on top of it must never see it move. Building it is the workspace package's (Builder); keeping, sharing and retiring it is this one's.
Index ¶
- Constants
- func ValidWarmName(name string) error
- type Builder
- type Key
- type Store
- func (store *Store) All() []Key
- func (store *Store) KeyOf(dir string) (Key, bool)
- func (store *Store) Let(ctx context.Context, key Key, user string) error
- func (store *Store) LetWarm(ctx context.Context, dir, user string) error
- func (store *Store) Retire(ctx context.Context, grace time.Duration) int
- func (store *Store) RetireWarm(ctx context.Context, grace time.Duration) int
- func (store *Store) SealWarm(ctx context.Context, sealed Warm, from string) error
- func (store *Store) Sweep() int
- func (store *Store) SweepWarm() int
- func (store *Store) Take(ctx context.Context, key Key, user string) (string, error)
- func (store *Store) TakeWarm(ctx context.Context, repository repo.Repo, name, user string) (Warm, error)
- func (store *Store) Users(key Key) []string
- func (store *Store) WarmAt(dir string) (Warm, error)
- func (store *Store) Warms(repository repo.Repo) []Warm
- type Warm
Constants ¶
const WarmDir = ".warm"
WarmDir is the directory under the templates where warm layers live. The templates' own walks never enter it.
Variables ¶
This section is empty.
Functions ¶
func ValidWarmName ¶
ValidWarmName says why name cannot name a warm layer, or nothing when it can.
Types ¶
type Builder ¶
type Builder interface {
// BuildTemplate checks key out at building, a directory that does not exist yet and
// that the store renames to final once it is complete.
BuildTemplate(ctx context.Context, key Key, building, final string) error
// ForgetTemplate undoes what building recorded elsewhere — the pools it borrows from —
// just before the template at dir is removed.
ForgetTemplate(ctx context.Context, key Key, dir string) error
}
Builder checks a template out, as the workspace package builds a workspace.
type Key ¶
Key is which template: a repository at a commit, with its submodules checked out or not.
type Store ¶
type Store struct {
Dir string
// contains filtered or unexported fields
}
Store keeps the templates under Dir.
func (*Store) KeyOf ¶
KeyOf reads a template's key back from its directory, when the directory is one.
func (*Store) LetWarm ¶
LetWarm says the workspace at user no longer stands on the warm layer at dir.
func (*Store) Retire ¶
Retire removes every template no workspace uses — none noted, or none of those noted still there — and nothing has taken for at least grace, and says how many it removed.
func (*Store) RetireWarm ¶
RetireWarm removes every warm layer no workspace stands on and nothing has taken for at least grace, and says how many it removed.
func (*Store) SealWarm ¶
SealWarm makes from, a layer a workspace left, the warm layer name of repository, by moving it, not copying: what overlay marked in it stays as it marked it. A warm layer of that name a workspace still stands on is not replaced.
func (*Store) Sweep ¶
Sweep removes what a gitd that died left half built under the templates directory: the temporary directories templates are built in, and the users files left half written. It does not look inside a template, which has nothing of the sort and many files, nor among the warm layers, which SweepWarm sweeps.
func (*Store) SweepWarm ¶
SweepWarm removes what a gitd that died left half done among the warm layers: a layer set aside to be replaced, or a file half written. It never enters a layer.
func (*Store) Take ¶
Take returns the template of key for the workspace at user, building it the first time, and notes that user uses it, so it is not retired under it.
func (*Store) TakeWarm ¶
func (store *Store) TakeWarm(ctx context.Context, repository repo.Repo, name, user string) (Warm, error)
TakeWarm returns the warm layer name of repository for the workspace at user, and notes that user stands on it, so it is neither replaced nor retired under it.
type Warm ¶
type Warm struct {
Repository repo.Repo
Name string
// Dir is the layer itself, mounted read-only.
Dir string
// Commit is the commit of the template it was sealed on: it stands on that one only.
Commit string
// Changed are the paths the layer changes that git does not ignore, as compared with
// its template, so that what a workspace changed is read without walking the layer.
Changed []string
// Sealed is when it was sealed, and From the workspace it was sealed from.
Sealed time.Time
From string
// Users is how many workspaces stand on it now.
Users int
}
Warm is a layer sealed from a workspace — what installing its dependencies wrote — that later workspaces of the same repository and commit stand on, between their template and their own layer. It is named per repository, and never changes once sealed: sealing the name again replaces it, once no workspace stands on it.