Documentation
¶
Overview ¶
Package pause is the emergency stop of icebath: a stop a user puts in force over everything or over one profile, under which nothing starts work on its own. It is kept on disk, so it outlives a restart and holds in every icebath of the settings folder within seconds, with who put it in force, when and why. The host names no feature: each feature that starts work registers what it holds and how it takes it up again, stops what it has going as a stop comes into force, and asks the host before it starts work
Index ¶
- Constants
- func Engaged(stop Stop, already, interrupted bool) string
- func Lifted(lifted []Stop, still Stop, held bool) string
- type Halter
- type Hold
- type Pause
- func (p *Pause) Changes() (<-chan struct{}, func())
- func (p *Pause) Engage(ctx context.Context, profile, by, reason string) (Stop, bool, int, error)
- func (p *Pause) Held(profile string) string
- func (p *Pause) Lift(ctx context.Context, scopes ...string) ([]Stop, error)
- func (p *Pause) Paused(profile string) (Stop, bool)
- func (p *Pause) Register(registrant Registrant)
- func (p *Pause) Scope(word string) (string, error)
- func (p *Pause) Stops() []Stop
- func (p *Pause) Telling(tell func(stop Stop, on bool))
- func (p *Pause) Watch(ctx context.Context) error
- type Registrant
- type Registry
- type Resumer
- type Stop
Constants ¶
const Everything = "all"
Word that names every profile as the scope of a stop
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Halter ¶
type Halter interface {
// Stops what the feature has going of the profile the stop holds, every profile's for a stop of everything, the stop said as why; how
// many things it stopped. Returns at once, what it stopped ending on its own
Halt(ctx context.Context, stop Stop) int
}
Registrant whose work goes on when a stop comes into force, which it stops, as the replies of the agent and the runs of the runner
type Hold ¶
type Hold struct {
// What is held, such as "Scheduled jobs" or "Messages of chat apps"
Title string
// What becomes of it while it is held and once the stop is lifted, a sentence: "Jobs due meanwhile run late or are skipped as each job's
// catch-up says."
Resume string
// How many of it wait now, -1 when they are not counted
Waiting int
}
One kind of work a feature holds while a stop is in force, as a user reads it
type Pause ¶
type Pause struct {
Registry
// contains filtered or unexported fields
}
The emergency stop of every icebath of the settings folder
func (*Pause) Changes ¶
func (p *Pause) Changes() (<-chan struct{}, func())
Changes returns a channel told each time a stop comes into force or is lifted, until stop is called.
func (*Pause) Engage ¶
Puts a stop in force over the profile, over everything for none, by who and for why as a user reads them: what holds from now on, whether a stop of the scope was in force already, whose time it keeps while it takes the new words, and how many things going on it stopped, as the settings of the profile it holds say whether it stops them. Every icebath of the settings folder holds it within seconds, and this one at once
func (*Pause) Held ¶
What holds the work of the profile, the notice of its stop. Empty while nothing holds it
func (*Pause) Lift ¶
Lifts the stops of the scopes, each a profile or empty for the stop of everything: those that were in force, which every icebath of the settings folder lets go of within seconds and this one at once
func (*Pause) Paused ¶
The stop holding the profile's work, checking the stop of everything first. false when none does. An empty profile checks only the stop of everything
func (*Pause) Register ¶
func (p *Pause) Register(registrant Registrant)
Adds a registrant. A registry nested in the host reaches the host through Host
func (*Pause) Scope ¶
The profile a scope word names, empty for everything: all, or a profile by its name with or without an at sign before it. An error a person reads for a profile there is not
func (*Pause) Telling ¶
Hands over what is told of each stop as it comes into force and as it is lifted in this process, such as the monitoring of icebath
func (*Pause) Watch ¶
Watch acts on stops that another icebath puts in force or lifts, until the context ends. It reads the stop files when the system reports a change to one (fsx.Watch). Unless that watch is trusted (fsx.Watch.Trusted), for example on a share, and until the watch has passed its proof in this process, it also looks every watchEvery. While a stop is in force here, each such look reads the stops. While none is, a look is one stat on the settings folder, and the stops are read only when the folder changed, when it changed too recently for its version to show a further change (fsx.Settled), and every watchFloor regardless. Every read takes the files fresh from disk.
type Registrant ¶
type Registrant interface {
// What the feature holds of the profile of the settings while a stop is in force, each kind of work it starts on its own. Read quickly
Holds(cfg *config.Config) []Hold
}
A feature that starts work on its own, such as a scheduler, a listener or the agent's replies: what of it a stop holds
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Holds ¶
What every registrant holds of the profile of the settings, in the order they were registered
func (*Registry) Host ¶
Host the registry is nested in, through which a plugin asks whether its work is held
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
type Resumer ¶
type Resumer interface {
// Takes up what the feature held of the profile the lifted stop held, every profile's for one of everything that no other stop holds
// still. The feature asks the host of any profile it is not sure of
Resume(ctx context.Context, lifted Stop)
}
Registrant that takes up what it held once a stop is lifted, such as the events a listener kept meanwhile
type Stop ¶
type Stop struct {
// Profile it holds, empty for a stop of every profile
Profile string `json:"profile,omitempty"`
// Who put it in force, as a user reads it, such as "you in the app" or "Alice on Telegram". Empty when not known
By string `json:"by,omitempty"`
At time.Time `json:"at"`
// Why, as the user who put it in force gave it. Empty for none
Reason string `json:"reason,omitempty"`
}
A stop in force
func (Stop) Notice ¶
What a user who wrote to icebath while the stop holds is told, a sentence or two
Directories
¶
| Path | Synopsis |
|---|---|
|
/pause and /unpause: the emergency stop of icebath, put in force over everything or over one profile and lifted.
|
/pause and /unpause: the emergency stop of icebath, put in force over everything or over one profile and lifted. |