Documentation ¶
Overview ¶
package gate provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.
Index ¶
- Variables
- func FlagManifold(config FlagManifoldConfig) dependency.Manifold
- func Manifold() dependency.Manifold
- func ManifoldEx(lock Lock) dependency.Manifold
- func NewFlagWorker(gate Waiter) (worker.Worker, error)
- type AlreadyUnlocked
- type Flag
- type FlagManifoldConfig
- type Lock
- type Unlocker
- type Waiter
Constants ¶
This section is empty.
Variables ¶
var ErrUnlocked = errors.New("gate unlocked")
ErrUnlocked indicates that a Flag's gate has been unlocked and it should be restarted to reflect the new value.
Functions ¶
func FlagManifold ¶
func FlagManifold(config FlagManifoldConfig) dependency.Manifold
FlagManifold runs a worker that implements engine.Flag such that it's only considered set when the referenced gate is unlocked.
func Manifold ¶
func Manifold() dependency.Manifold
Manifold returns a dependency.Manifold that wraps a single channel, shared across all workers returned by the start func; it can be used to synchronize operations across manifolds that lack direct dependency relationships.
The output func accepts an out pointer to either an Unlocker or a Waiter.
func ManifoldEx ¶
func ManifoldEx(lock Lock) dependency.Manifold
ManifoldEx does the same thing as Manifold but takes the Lock which used to wait on or unlock the gate. This allows code running outside of a dependency engine managed worker to monitor or unlock the gate.
TODO(mjs) - this can likely go away once all machine agent workers are running inside the dependency engine.
func NewFlagWorker ¶
Types ¶
type AlreadyUnlocked ¶
type AlreadyUnlocked struct{}
AlreadyUnlocked is a Waiter that always reports its gate to be unlocked.
func (AlreadyUnlocked) IsUnlocked ¶
func (AlreadyUnlocked) IsUnlocked() bool
IsUnlocked is part of the Waiter interface.
func (AlreadyUnlocked) Unlocked ¶
func (AlreadyUnlocked) Unlocked() <-chan struct{}
Unlocked is part of the Waiter interface.
type Flag ¶
type Flag struct {
// contains filtered or unexported fields
}
Flag uses a gate to implement engine.Flag.
type FlagManifoldConfig ¶
type FlagManifoldConfig struct { GateName string NewWorker func(gate Waiter) (worker.Worker, error) }
FlagManifoldConfig holds the dependencies required to run a Flag in a dependency.Engine.