overflow_discovery/server/server.go
crusader 3ceb82880a ing
2018-03-21 19:34:40 +09:00

38 lines
903 B
Go

package server
import (
cdr "git.loafle.net/commons_go/di/registry"
"git.loafle.net/commons_go/logging"
crr "git.loafle.net/commons_go/rpc/registry"
"git.loafle.net/commons_go/server"
oodca "git.loafle.net/overflow/overflow_discovery/commons/annotation"
oods "git.loafle.net/overflow/overflow_discovery/service"
oopcs "git.loafle.net/overflow/overflow_probe_container/server"
)
func New(pidPath string) server.Server {
var (
services []interface{}
err error
)
oods.InitService()
rpcRegistry := crr.NewRPCRegistry()
if services, err = cdr.GetInstancesByAnnotationName(oodca.ServiceTag); nil != err {
logging.Logger().Panic(err)
}
for _, s := range services {
rpcRegistry.RegisterService(s, "")
}
rpcSH := oopcs.NewRPCServletHandler(rpcRegistry)
socketHandler := newSocketHandler(rpcSH)
sh := newServerHandler(pidPath, socketHandler)
s := oopcs.New(sh)
return s
}