Documentation ¶
Overview ¶
Package lifecycle provides application models' lifecycle management.
Index ¶
- Variables
- type Lifecycle
- func (lc *Lifecycle) Add(m Model)
- func (lc *Lifecycle) AddModels(m ...Model)
- func (lc *Lifecycle) OnStart(ctx context.Context) error
- func (lc *Lifecycle) OnStartSequentially(ctx context.Context) error
- func (lc *Lifecycle) OnStop(ctx context.Context) error
- func (lc *Lifecycle) OnStopSequentially(ctx context.Context) error
- type Model
- type Readiness
- type StartStopper
- type Starter
- type Stopper
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.
func (*Lifecycle) OnStartSequentially ¶ added in v1.8.0
OnStartSequentially runs models' Start function if models implmented it.
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.