mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-09 12:58:15 +03:00
refactor: Modular inbound/outbound manager
This commit is contained in:
33
adapter/lifecycle_legacy.go
Normal file
33
adapter/lifecycle_legacy.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package adapter
|
||||
|
||||
type LegacyPreStarter interface {
|
||||
PreStart() error
|
||||
}
|
||||
|
||||
type LegacyPostStarter interface {
|
||||
PostStart() error
|
||||
}
|
||||
|
||||
func LegacyStart(starter any, stage StartStage) error {
|
||||
switch stage {
|
||||
case StartStateInitialize:
|
||||
if preStarter, isPreStarter := starter.(interface {
|
||||
PreStart() error
|
||||
}); isPreStarter {
|
||||
return preStarter.PreStart()
|
||||
}
|
||||
case StartStateStart:
|
||||
if starter, isStarter := starter.(interface {
|
||||
Start() error
|
||||
}); isStarter {
|
||||
return starter.Start()
|
||||
}
|
||||
case StartStatePostStart:
|
||||
if postStarter, isPostStarter := starter.(interface {
|
||||
PostStart() error
|
||||
}); isPostStarter {
|
||||
return postStarter.PostStart()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user