2024-11-09 13:16:11 +00:00
|
|
|
package adapter
|
|
|
|
|
|
|
|
type StartStage uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
StartStateInitialize StartStage = iota
|
|
|
|
StartStateStart
|
|
|
|
StartStatePostStart
|
|
|
|
StartStateStarted
|
|
|
|
)
|
|
|
|
|
|
|
|
var ListStartStages = []StartStage{
|
|
|
|
StartStateInitialize,
|
|
|
|
StartStateStart,
|
|
|
|
StartStatePostStart,
|
|
|
|
StartStateStarted,
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s StartStage) Action() string {
|
|
|
|
switch s {
|
|
|
|
case StartStateInitialize:
|
|
|
|
return "initialize"
|
|
|
|
case StartStateStart:
|
|
|
|
return "start"
|
|
|
|
case StartStatePostStart:
|
|
|
|
return "post-start"
|
|
|
|
case StartStateStarted:
|
|
|
|
return "start-after-started"
|
|
|
|
default:
|
|
|
|
panic("unknown stage")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-10 08:46:59 +00:00
|
|
|
type Lifecycle interface {
|
|
|
|
Start(stage StartStage) error
|
2024-11-09 13:16:11 +00:00
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2024-11-10 08:46:59 +00:00
|
|
|
type LifecycleService interface {
|
|
|
|
Name() string
|
|
|
|
Lifecycle
|
2024-11-09 13:16:11 +00:00
|
|
|
}
|