Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HubCmd = &cobra.Command{ Use: "hub", Short: "Graffiti hub", Long: "Graffiti hub", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { logging.GetLogger().Noticef("Graffiti hub starting...") sa, err := common.ServiceAddressFromString(hubListen) if err != nil { logging.GetLogger().Errorf("Configuration error: %s", err) os.Exit(1) } hostname, err := os.Hostname() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } persistent, err := graph.NewMemoryBackend() if err != nil { logging.GetLogger().Error(err) os.Exit(1) } cached, err := graph.NewCachedBackend(persistent) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } service := common.Service{ID: hostname, Type: "Hub"} g := graph.NewGraph(hostname, cached, serviceType) httpServer := shttp.NewServer(hostname, service.Type, sa.Addr, sa.Port, nil) if err := httpServer.Listen(); err != nil { logging.GetLogger().Error(err) os.Exit(1) } authBackend := shttp.NewNoAuthenticationBackend() tr := traversal.NewGremlinTraversalParser() tr.AddTraversalExtension(ge.NewDescendantsTraversalExtension()) if _, err = api.NewAPI(httpServer, nil, service, authBackend); err != nil { logging.GetLogger().Error(err) os.Exit(1) } api.RegisterTopologyAPI(httpServer, g, tr, authBackend) serverOpts := websocket.ServerOpts{ WriteCompression: writeCompression, QueueSize: queueSize, PingDelay: time.Second * time.Duration(pingDelay), PongTimeout: time.Second * time.Duration(pongTimeout), } hubOpts := hub.Opts{ ServerOpts: serverOpts, } hub, err := hub.NewHub(httpServer, g, cached, authBackend, authBackend, nil, "/ws/pod", nil, hubOpts) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } go httpServer.Serve() hub.Start() logging.GetLogger().Notice("Graffiti hub started !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch logging.GetLogger().Notice("Graffiti hub stopped.") }, }
HubCmd describes the graffiti hub command
View Source
var PodCmd = &cobra.Command{ Use: "pod", Short: "Graffiti pod", Long: "Graffiti pod", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { logging.GetLogger().Noticef("Graffiti pod starting...") sa, err := common.ServiceAddressFromString(podListen) if err != nil { logging.GetLogger().Errorf("Configuration error: %s", err) os.Exit(1) } hostname, err := os.Hostname() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } service := common.Service{ID: hostname, Type: serviceType} backend, err := graph.NewMemoryBackend() if err != nil { logging.GetLogger().Errorf("Failed to get hostname: %s", err) os.Exit(1) } clusterAuthOptions := &shttp.AuthenticationOpts{} tr := traversal.NewGremlinTraversalParser() tr.AddTraversalExtension(ge.NewDescendantsTraversalExtension()) g := graph.NewGraph(hostname, backend, serviceType) authBackend := shttp.NewNoAuthenticationBackend() httpServer := shttp.NewServer(hostname, serviceType, sa.Addr, sa.Port, nil) if err := httpServer.Listen(); err != nil { logging.GetLogger().Error(err) os.Exit(1) } apiServer, err := api.NewAPI(httpServer, nil, service, authBackend) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } api.RegisterTopologyAPI(httpServer, g, tr, authBackend) var addresses []common.ServiceAddress for _, address := range hubServers { sa, err := common.ServiceAddressFromString(address) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } addresses = append(addresses, sa) } if len(addresses) == 0 { logging.GetLogger().Info("Pod is running in standalone mode") } clientOpts := websocket.ClientOpts{ AuthOpts: clusterAuthOptions, WriteCompression: writeCompression, QueueSize: queueSize, } clientPool := newHubClientPool(hostname, addresses, clientOpts) podOpts := pod.Opts{ ServerOpts: websocket.ServerOpts{ WriteCompression: writeCompression, QueueSize: queueSize, PingDelay: time.Second * time.Duration(pingDelay), PongTimeout: time.Second * time.Duration(pongTimeout), }, } pod, err := pod.NewPod(apiServer, clientPool, g, authBackend, nil, tr, podOpts) if err != nil { logging.GetLogger().Error(err) os.Exit(1) } go httpServer.Serve() go clientPool.ConnectAll() pod.Start() logging.GetLogger().Notice("Graffiti pod started !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch logging.GetLogger().Notice("Graffiti pod stopped.") }, }
PodCmd describes the graffiti pod command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.