Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "shar", Short: "SHAR Server", Long: ``, Run: func(cmd *cobra.Command, args []string) { ctx := context.WithValue(context.Background(), ctxkey.Service, "shar-server") if err := global_telemetry.Setup(ctx, "shar-server"); err != nil { panic(fmt.Errorf("setup telemetry: %w", err)) } log := global_telemetry.DefaultLogger(ctx, true) cfg, err := config.GetEnvironment() if err != nil { log.Log(ctx, errors.FatalLevel, err.Error()) } nc, err := server.ConnectNats(cfg.JetStreamDomain, cfg.NatsURL, []nats.Option{nats.MaxReconnects(cfg.NatsMaxReconnects)}, false) if err != nil { panic(fmt.Errorf("connect nats: %w", err)) } options := []option.Option{option.Concurrency(cfg.Concurrency), option.NatsUrl(cfg.NatsURL), option.GrpcPort(cfg.Port)} if cfg.JetStreamDomain != "" { options = append(options, option.WithJetStreamDomain(cfg.JetStreamDomain)) } switch cfg.HistoryStore { case "nats": options = append(options, option.WithHistoryStore(option.NatsKV, "")) case "postgres": options = append(options, option.WithHistoryStore(option.Postgres, cfg.HistoryStoreConnection)) } var svr *server.Server if svr, err = server.New(nc, options...); err != nil { panic(fmt.Errorf("creating server: %w", err)) } if err = svr.Listen(); err != nil { panic(fmt.Errorf("starting server: %w", err)) } }, PersistentPreRun: func(cmd *cobra.Command, args []string) { }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.