package server import ( od "git.loafle.net/overflow/di-go" olog "git.loafle.net/overflow/log-go" orpj "git.loafle.net/overflow/rpc-go/protocol/json" orr "git.loafle.net/overflow/rpc-go/registry" ossw "git.loafle.net/overflow/server-go/socket/web" "git.loafle.net/overflow_scanner/probe/annotation" "git.loafle.net/overflow_scanner/probe/discovery" "git.loafle.net/overflow_scanner/probe/internal/pubsub" // For service _ "git.loafle.net/overflow_scanner/probe/service" ) func New() *ossw.Server { rpcServerCodec := orpj.NewServerCodec() _pubsub := pubsub.New(10) od.RegisterSingletonByName("Discoverer", discovery.Instance()) od.RegisterSingletonByName("PubSub", _pubsub) services, err := od.GetInstancesByAnnotationType(annotation.ServiceAnnotationType) if nil != err { olog.Logger().Panic(err.Error()) } rpcRegistry := orr.NewRPCRegistry() rpcRegistry.RegisterServices(services...) ss := &ScannerServlets{} ss.RPCInvoker = rpcRegistry ss.RPCServerCodec = rpcServerCodec ss.PubSub = _pubsub sh := &ServerHandlers{} sh.Name = "Probe" sh.Services = services sh.PubSub = _pubsub sh.RegisterServlet("/scanner", ss) s := &ossw.Server{ ServerHandler: sh, } return s }