crusader c40d8eb004 ing
2018-04-19 20:36:56 +09:00

43 lines
1.1 KiB
Go

package server
import (
cdr "git.loafle.net/commons/di-go/registry"
logging "git.loafle.net/commons/logging-go"
crr "git.loafle.net/commons/rpc-go/registry"
cssn "git.loafle.net/commons/server-go/socket/net"
occa "git.loafle.net/overflow/commons-go/core/annotation"
"git.loafle.net/overflow/container-go"
"git.loafle.net/overflow/container_discovery/crawler"
"git.loafle.net/overflow/container_discovery/service"
"git.loafle.net/overflow/container_discovery/servlet"
)
func New(pidFilePath string) *cssn.Server {
cdr.RegisterResource(container.CONTAINER_CRAWLERS, crawler.GetCrawlers())
services, err := cdr.GetInstancesByAnnotationType(occa.RPCServiceAnnotationType)
if nil != err {
logging.Logger().Panic(err)
}
rpcRegistry := crr.NewRPCRegistry()
rpcRegistry.RegisterServices(services...)
ds := &servlet.DiscoveryServlets{}
ds.RPCInvoker = rpcRegistry
sh := &ServerHandlers{}
sh.Name = "Container Discovery"
sh.PIDFilePath = pidFilePath
sh.Services = services
sh.OrderedServices = service.OrderedServices
sh.RegisterServlet(ds)
s := &cssn.Server{
ServerHandler: sh,
}
return s
}