Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNopLifecycle ¶ added in v1.8.0
NewNopLifecycle returns a new one-time no-op lifecycle
Types ¶
type ErrorWaiter ¶
type ErrorWaiter struct {
// contains filtered or unexported fields
}
ErrorWaiter is similar to a WaitGroup except it allows collecting failures from subtasks.
func (*ErrorWaiter) Submit ¶
func (ew *ErrorWaiter) Submit(f func() error)
Submit submits a task for execution on the ErrorWaiter.
The function returns immediately.
func (*ErrorWaiter) Wait ¶
func (ew *ErrorWaiter) Wait() []error
Wait waits until all submitted tasks have finished and returns a list of all errors that occurred during task execution in no particular order.
type LifecycleOnce ¶ added in v1.0.0
type LifecycleOnce interface { Start(func() error) error Stop(func() error) error LifecycleState() LifecycleState IsRunning() bool WhenRunning(context.Context) error Stopped() <-chan struct{} Started() <-chan struct{} }
LifecycleOnce is a helper for implementing transport.Lifecycles with similar behavior.
func Once ¶ added in v1.4.0
func Once() LifecycleOnce
Once returns a lifecycle controller.
- The observable lifecycle state must only go forward from birth to death.
- Start() must block until the state is >= Running
- Stop() must block until the state is >= Stopped
- Stop() must pre-empt Start() if it occurs first
- Start() and Stop() may be backed by a do actual work function, and that function must be called at most once.
type LifecycleState ¶ added in v1.0.0
type LifecycleState int
LifecycleState represents `states` that a lifecycle object can be in.
const ( // Idle indicates the Lifecycle hasn't been operated on yet. Idle LifecycleState = iota // Starting indicates that the Lifecycle has begun it's "start" command // but hasn't finished yet. Starting // Running indicates that the Lifecycle has finished starting and is // available. Running // Stopping indicates that the Lifecycle 'stop' method has been called // but hasn't finished yet. Stopping // Stopped indicates that the Lifecycle has been stopped. Stopped // Errored indicates that the Lifecycle experienced an error and we can't // reasonably determine what state the lifecycle is in. Errored )
func (LifecycleState) String ¶ added in v1.4.0
func (i LifecycleState) String() string
Click to show internal directories.
Click to hide internal directories.