Documentation
¶
Overview ¶
Package role is how a controller or a runner goes about its work, wherever it is hosted: in passes.
Index ¶
- Constants
- func Gone(pid int) bool
- func LimitMemory(limit uint64)
- func Lost()
- 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, now func() time.Time, report func(role string, err error), ...)
- func Serve(ctx context.Context, report func(role string, err error), roles ...Role) error
- func Serverless() bool
- func StoreFits(address string) error
- func Watch(pid int, limit int64, done <-chan struct{}, over func())
- func WatchOwn(ctx context.Context, limit int64, over func())
- type Pass
- type Process
- type Role
- type Wire
Constants ¶
const Arg = "run-one-job"
Arg is the argument that makes the binary run one piece of work, as the process that is started for it.
const Grace = 2 * time.Second
Grace is how long a process that is told to stop is given before it is killed, and how long its output is read after it has ended.
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.
const MaxPiece = 64 << 20
MaxPiece bounds one piece; a blob's bytes are not counted.
Variables ¶
This section is empty.
Functions ¶
func LimitMemory ¶ added in v0.12.0
func LimitMemory(limit uint64)
LimitMemory has the system refuse this process more memory than a limit past what it has reserved so far, so that a request for more ends it at once and fills nothing. Go reserves about a gigabyte of addresses it never uses, and the system counts addresses.
func Lost ¶ added in v0.12.0
func Lost()
Lost ends the process, and everything it started with it: its starter has gone away, and nothing else would stop them.
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, 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 role's 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.
func StoreFits ¶
StoreFits refuses, on a serverless host, a store that is a directory or memory. Copies on such a host share no disk and no memory, so each would see a store of its own.
Types ¶
type Pass ¶
A Pass looks at the store, does everything that is owed, and stops. It says when the next thing is due, if it knows of one. Nothing is carried in memory from one pass to the next.
type Process ¶ added in v0.12.0
A Process is a process started with a channel to it. Nothing but the starter holds its ends of the channel.
func Start ¶ added in v0.12.0
Start starts a command in a group of its own, in a directory, with what it prints going to out.
func (*Process) Close ¶ added in v0.12.0
func (p *Process) Close()
Close ends the process and closes the starter's ends of the channel.
type Role ¶
A Role is one role of a process: its pass, how long it sleeps when nothing is due, and the notice its store gives when something it reads is written by this same process.
type Wire ¶ added in v0.12.0
A Wire is one end of the channel.
func Open ¶ added in v0.12.0
Open is how a process started by Start begins: it takes its ends of the channel, and makes itself a group where the system needs that. Everything it starts is in that group, and goes when the group is ended.
func (*Wire) ReceiveUpTo ¶ added in v0.12.0
ReceiveUpTo reads one piece of at most a number of bytes, as it was sent.