55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
cs "git.loafle.net/commons/server-go"
|
|
oe "git.loafle.net/overflow/external-go"
|
|
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
|
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
|
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
|
)
|
|
|
|
type ServerHandler interface {
|
|
ogrs.ServerHandler
|
|
}
|
|
|
|
type ServerHandlers struct {
|
|
ogrs.ServerHandlers
|
|
|
|
Config *config.Config
|
|
}
|
|
|
|
func (sh *ServerHandlers) Init(serverCtx cs.ServerCtx) error {
|
|
if err := sh.ServerHandlers.Init(serverCtx); nil != err {
|
|
return err
|
|
}
|
|
oe.InitPackage(sh.Config.External)
|
|
subscribe.InitPackage()
|
|
|
|
return nil
|
|
}
|
|
|
|
func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
|
|
if err := sh.ServerHandlers.OnStart(serverCtx); nil != err {
|
|
return err
|
|
}
|
|
|
|
oe.StartPackage(sh.Config.External)
|
|
subscribe.StartPackage()
|
|
|
|
return nil
|
|
}
|
|
|
|
func (sh *ServerHandlers) OnStop(serverCtx cs.ServerCtx) {
|
|
subscribe.StopPackage()
|
|
oe.StopPackage(sh.Config.External)
|
|
|
|
sh.ServerHandlers.OnStop(serverCtx)
|
|
}
|
|
|
|
func (sh *ServerHandlers) Destroy(serverCtx cs.ServerCtx) {
|
|
subscribe.DestroyPackage()
|
|
oe.DestroyPackage(sh.Config.External)
|
|
|
|
sh.ServerHandlers.Destroy(serverCtx)
|
|
}
|