mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-27 02:51:36 +00:00
43 lines
694 B
Go
43 lines
694 B
Go
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")
|
|
}
|
|
}
|
|
|
|
type Lifecycle interface {
|
|
Start(stage StartStage) error
|
|
Close() error
|
|
}
|
|
|
|
type LifecycleService interface {
|
|
Name() string
|
|
Lifecycle
|
|
}
|