Skip to main content

Module service_work

Module service_work 

Source
Expand description

The service’s consumer of after-commit push and upkeep work. What: The service’s consumer of after-commit work: pending push and maintenance work items of one repository are claimed, coalesced, run, settled, and a push that failed leaves a plain notice for the person’s next commit. Why: A commit must not wait for the network or for upkeep, so the wrapper leaves a record and the resident service does the work on its own thread (doc/planning/cli-git-resident-service.md, “After-commit work”). The service is the only pusher of the repositories it serves, so no lock is needed: several pending pushes of one branch become one push, and a service that died mid-push is noticed by the claim’s lease, never by a process id. Other kinds of work (the standards review) are never claimed here.

In TS you’d write (pseudocode):

for (const group of coalesce(await claimAll(workDir, ['push', 'maintenance']))) settle(group, await handler(group));

Structs§

GitHandlers
The handlers that run real Git.

Enums§

Verdict
What a handler came to.

Constants§

LEASE
How long a claim stands before it is taken back: longer than a push’s whole budget, so a push that is merely slow is never run twice at once.
MAX_TRIES
How many times an item is tried before it is given up on.
NOTICE_DIRECTORY
Directory under the common Git directory that holds notices for the person.
SERVICE_KINDS
The kinds of work the service runs itself.

Traits§

WorkHandlers
What runs each kind of work.

Functions§

drain
What: Runs everything pending for one repository: takes back expired claims, claims every pending push and maintenance item, runs one push per branch and one upkeep per repository, settles the items, and leaves a notice for each failed push. Why: Coalescing keeps a burst of commits to one push; a handler that fails leaves the items in failed, not in a loop.
is_acceptable
What: Whether an item is one this service should act on for this repository. Why: Anyone who can write the work directory can write an item, so the fields that become a directory, a reference or a program argument are checked before they are used.
notice_directory
The notice directory of a repository.
take_notices
What: Reads and removes the repository’s notices, oldest name first. Why: A notice is shown once, by the next commit that goes through the service.
work_directory
The work directory of a repository.
write_notice
Leaves a notice for the person, named after the work item so a repeat replaces it.