Documentation
¶
Overview ¶
Package role is how a controller or a runner goes about its work, wherever it is hosted: in passes.
Index ¶
- Constants
- func Once(ctx context.Context, until time.Time, margin time.Duration, pass Pass) (time.Time, error)
- func OwnConfig(dir string) (string, error)
- func Run(ctx context.Context, interval time.Duration, now func() time.Time, ...)
- func Serve(ctx context.Context, report func(role string, err error), roles ...Role) error
- func Serverless() bool
- func StoreFits(address string) error
- type Pass
- type Role
Constants ¶
const HostMargin = 10 * time.Second
HostMargin is how long before the host's limit a pass stops taking up new work, to finish what it has in hand.
Variables ¶
This section is empty.
Functions ¶
func Once ¶
Once runs one pass for a host that calls for passes itself and kills a copy at a time it gives. The pass is told to stop taking up new work a margin before that time, or halfway to it where less than two margins are left, and nothing of it goes on after it has answered.
func OwnConfig ¶
OwnConfig gives the config directory a role is to use. A serverless host unpacks its package read-only and readable by everyone, and an identity that others can read is not accepted: there the config is copied to a place of the copy's own, made its owner's alone, and that place is given. Anywhere else the config is used where it is.
func Run ¶
func Run(ctx context.Context, interval time.Duration, now func() time.Time, report func(role string, err error), roles ...Role)
Run runs each role's passes in a loop until the context ends: a pass, then a sleep until the next thing is due or for the interval, whichever is sooner. A role is woken at once when another role in the process writes something it reads; that changes when a pass happens and never what a pass does.
report is told of each pass that failed. Such a pass has failed nothing: what was waiting is still waiting for the next one.
func Serve ¶
Serve answers the host's calls until the context ends: for each call, one pass of each role, and then the answer. Nothing of a pass goes on after it has answered.
func Serverless ¶
func Serverless() bool
Serverless says whether the process is on a host that calls for passes itself.