mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-07 05:47:36 +03:00
refactor: Modular inbound/outbound manager
This commit is contained in:
parent
0f7ffeed5c
commit
3310d0716e
69 changed files with 1186 additions and 754 deletions
41
adapter/lifecycle.go
Normal file
41
adapter/lifecycle.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
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 NewService interface {
|
||||
NewStarter
|
||||
Close() error
|
||||
}
|
||||
|
||||
type NewStarter interface {
|
||||
Start(stage StartStage) error
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue