package server import ( cdr "git.loafle.net/commons/di-go/registry" logging "git.loafle.net/commons/logging-go" crpj "git.loafle.net/commons/rpc-go/protocol/json" 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 { rpcWriteChan := make(chan *container.RPCNotification, 256) cdr.RegisterResource(container.CONTAINER_CRAWLERS, crawler.GetCrawlers()) cdr.RegisterResource(container.CONTAINER_RPC_WRITE_CHAN, rpcWriteChan) 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 ds.RPCWriteChan = rpcWriteChan ds.RPCServerCodec = crpj.NewServerCodec() 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 }