Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRunning = errors.New("lifecycle: still running")
Functions ¶
This section is empty.
Types ¶
type Lifecycle ¶
type Lifecycle interface {
LifecycleReader
// ShutdownRequest() returns a channel that is available for reading when
// a shutdown has requested.
ShutdownRequest() <-chan error
// ShutdownInitiated() declares that shutdown has begun. Will panic if called twice.
ShutdownInitiated(error)
// ShutdownCompleted() declares that shutdown has completed. Will panic if called twice.
ShutdownCompleted()
// WatchContext() observes the given context and initiates a shutdown
// if the context is shutdown before the lifecycle is.
WatchContext(context.Context)
// Begins shutdown when given channel is ready for reading.
WatchChannel(<-chan struct{})
// Shutdown() initiates shutdown by sending a value to the channel
// requtned by ShutdownRequest() and blocks untill ShutdownCompleted()
// is called.
Shutdown(error)
// Initiate shutdown but does not block until complete.
ShutdownAsync(error)
}
type LifecycleReader ¶
type LifecycleReader interface {
// ShuttingDown() returns a channel that is available for reading
// after ShutdownInitiated() has been called.
ShuttingDown() <-chan struct{}
// Done() returns a channel that is available for reading
// after ShutdownCompleted() has been called.
Done() <-chan struct{}
Error() error
}
LifecycleReader exposes read-only access to lifecycle state.
Click to show internal directories.
Click to hide internal directories.