2018-04-12 12:07:02 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
cs "git.loafle.net/commons/server-go"
|
2018-05-11 08:20:11 +00:00
|
|
|
oe "git.loafle.net/overflow/external-go"
|
2018-04-12 12:07:02 +00:00
|
|
|
ogrs "git.loafle.net/overflow/gateway_rpc/server"
|
2018-04-26 08:17:12 +00:00
|
|
|
"git.loafle.net/overflow/probe_gateway_rpc/config"
|
|
|
|
"git.loafle.net/overflow/probe_gateway_rpc/subscribe"
|
2018-04-12 12:07:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2018-05-11 08:20:11 +00:00
|
|
|
oe.InitPackage(sh.Config.External)
|
2018-04-12 12:07:02 +00:00
|
|
|
subscribe.InitPackage()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *ServerHandlers) OnStart(serverCtx cs.ServerCtx) error {
|
|
|
|
if err := sh.ServerHandlers.OnStart(serverCtx); nil != err {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-11 08:20:11 +00:00
|
|
|
oe.StartPackage(sh.Config.External)
|
2018-04-12 12:07:02 +00:00
|
|
|
subscribe.StartPackage()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *ServerHandlers) OnStop(serverCtx cs.ServerCtx) {
|
|
|
|
subscribe.StopPackage()
|
2018-05-11 08:20:11 +00:00
|
|
|
oe.StopPackage(sh.Config.External)
|
2018-04-12 12:07:02 +00:00
|
|
|
|
|
|
|
sh.ServerHandlers.OnStop(serverCtx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *ServerHandlers) Destroy(serverCtx cs.ServerCtx) {
|
|
|
|
subscribe.DestroyPackage()
|
2018-05-11 08:20:11 +00:00
|
|
|
oe.DestroyPackage(sh.Config.External)
|
2018-04-12 12:07:02 +00:00
|
|
|
|
|
|
|
sh.ServerHandlers.Destroy(serverCtx)
|
|
|
|
}
|