package supervisor

Import Path
	go.pact.im/x/supervisor (on go.dev)

Dependency Relation
	imports 9 packages, and imported by 0 packages

Involved Source Files errors.go options.go restart.go startstop.go Package supervisor provides a supervisor implementation for starting, stopping, and monitoring its child processes. table.go
Package-Level Type Names (total 5, in which 4 are exported)
/* sort exporteds by: | */
Type Parameters: K: comparable V: any Iterator iterates over key and value pairs in the Table. It follows the semantics of the standard sql.Rows type and does not necessarily correspond to any consistent snapshot of the Table’s contents. Close closes the iterator. Err returns any error that occurred during iteration. Get returns the key and value for the current iteration. Next prepares the value for the next iteration. It returns true on success, and false if there is no next value. Consult Err to check whether iterator successfully reached the end or an error occurred. Iterator : io.Closer func Table[K, V].Iter(ctx context.Context) (Iterator[K, V], error)
Options is a set of options for supervisor constructor. Clock is the clock to use. Defaults to system clock. func NewSupervisor[K, P](t Table[K, P], o Options) *Supervisor[K, P]
Type Parameters: K: comparable P: process.Runnable Supervisor is responsible for starting, stopping, and monitoring its child processes. Get returns a running process or either a ErrProcessNotFound error if the process does not exist or ErrProcessNotRunning is the process exists but is not running. Keys returns a list of all process keys. Run starts the supervisor and executes callback on successful initialization. Start starts the process with the given key from the table. It returns ErrNotRunning if the supervisor is not running and ErrProcessExists if the process already exists. Otherwise it returns an error from process initialization. Stop stops the process with the given key. It returns ErrProcessNotFound if the process does not exist, and an error from running the process otherwise. *Supervisor : go.pact.im/x/process.Runnable func NewSupervisor[K, P](t Table[K, P], o Options) *Supervisor[K, P]
Type Parameters: K: comparable V: any Table defines a table of key and value pairs that is potentially backed by a persistent and shared storage. Get returns the value for the given key. Iter returns an iterator for key and value pairs in the table. func NewSupervisor[K, P](t Table[K, P], o Options) *Supervisor[K, P]
Package-Level Functions (only one, which is exported)
Type Parameters: K: comparable P: process.Runnable NewSupervisor returns a new Supervisor instance. The given table is used to lookup managed processes and periodically restart failed units (or processes that were added externally). Managed processes are uniquely identifiable by key. A managed process may remove itself from the Supervisor by deleting the associated entry from the table before terminating. Likewise, to stop a process, it must be removed from the table prior to Stop call. That is, processes must be aware of being managed and the removal is tighly coupled with the table. As a rule of thumb, to keep the underlying table consistent, processes should not be re-added to table after being removed from the table. It is possible to implement re-adding on top of the Supervisor but that requires handling possible orderings of table removal, addition, re-addition and process startup, shutdown and self-removal (or a subset of these operations depending on the use cases).
Package-Level Variables (total 4, all are exported)
ErrNotRunning is an error that is returned when a process supervisor temporarily unavailable (i.e. it is not running).
ErrProcessExists is an error that is returned if the process already exists for the given ID.
ErrProcessNotFound is an error that is returned if the requested process was not found.
ErrProcessNotRunning is an error that is returned when a process is not running (i.e. exists but is in the starting state).
Package-Level Constants (total 3, none are exported)