Documentation ¶
Overview ¶
Package lifecycle provides application models' lifecycle management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrWrongState = errors.New("service is in wrong state")
)
vars
Functions ¶
This section is empty.
Types ¶
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
Lifecycle manages lifecycle for models. Currently a Lifecycle has two phases: Start and Stop. Currently Lifecycle doesn't support soft dependency models and multi-err, so all models in Lifecycle require to be succeed on both phases.
func (*Lifecycle) OnStart ¶
OnStart runs models OnStart function if models implmented it. All OnStart functions will be run in parallel. context passed into models' OnStart method will be canceled on the first time a model's OnStart function return non-nil error.
type Model ¶
type Model interface{}
Model is application model which may require to start and stop in application lifecycle.
type Readiness ¶ added in v1.7.1
type Readiness struct {
// contains filtered or unexported fields
}
Readiness is a thread-safe struct to indicate a service's status
func (*Readiness) IsReady ¶ added in v1.7.1
IsReady returns whether the service is ready (can accept service request)
type StartStopper ¶
StartStopper is the interface that groups Start and Stop.