Documentation ¶
Overview ¶
Package cmd provides the command line interface for the Executor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ExecutorInfoCommand = &cli.Command{ Name: "executor-info", Description: "learn how to use executor cli", Action: func(c *cli.Context) error { fmt.Println(string(markdown.Render(help, termsize.Width(), 6))) return nil }, }
ExecutorInfoCommand gets info about using the executor agent.
View Source
var ExecutorRunCommand = &cli.Command{ Name: "executor-run", Description: "runs the executor service", Flags: []cli.Flag{configFlag, metricsPortFlag, debugFlag}, Action: func(c *cli.Context) error { var scribeClient client.ScribeClient g, ctx := errgroup.WithContext(c.Context) handler, err := metrics.NewFromEnv(ctx, metadata.BuildInfo()) if err != nil { return fmt.Errorf("failed to create metrics handler: %w", err) } executorConfig, executorDB, err := createExecutorParameters(ctx, c, handler) if err != nil { return err } switch executorConfig.ScribeConfig.Type { case "embedded": eventDB, err := scribeAPI.InitDB( ctx, executorConfig.ScribeConfig.EmbeddedDBConfig.Type, executorConfig.ScribeConfig.EmbeddedDBConfig.Source, handler, false, ) if err != nil { return fmt.Errorf("failed to initialize database: %w", err) } scribeClients := make(map[uint32][]backend.ScribeBackend) for _, client := range executorConfig.ScribeConfig.EmbeddedScribeConfig.Chains { for confNum := 1; confNum <= scribeCmd.MaxConfirmations; confNum++ { backendClient, err := backend.DialBackend(ctx, fmt.Sprintf("%s/%d/rpc/%d", executorConfig.BaseOmnirpcURL, confNum, client.ChainID), handler) if err != nil { return fmt.Errorf("could not start client for %s", fmt.Sprintf("%s/1/rpc/%d", executorConfig.BaseOmnirpcURL, client.ChainID)) } scribeClients[client.ChainID] = append(scribeClients[client.ChainID], backendClient) } } scribe, err := service.NewScribe(eventDB, scribeClients, executorConfig.ScribeConfig.EmbeddedScribeConfig, handler) if err != nil { return fmt.Errorf("failed to initialize scribe: %w", err) } g.Go(func() error { err := scribe.Start(ctx) if err != nil { return fmt.Errorf("failed to start scribe: %w", err) } return nil }) embedded := client.NewEmbeddedScribe( executorConfig.ScribeConfig.EmbeddedDBConfig.Type, executorConfig.ScribeConfig.EmbeddedDBConfig.Source, handler, ) g.Go(func() error { err := embedded.Start(ctx) if err != nil { return fmt.Errorf("failed to start embedded scribe: %w", err) } return nil }) scribeClient = embedded.ScribeClient case "remote": scribeClient = client.NewRemoteScribe( uint16(executorConfig.ScribeConfig.Port), executorConfig.ScribeConfig.URL, handler, ).ScribeClient default: return fmt.Errorf("invalid scribe type: %s", executorConfig.ScribeConfig.Type) } var baseOmniRPCClient omnirpcClient.RPCClient if debugFlag.IsSet() { baseOmniRPCClient = omnirpcClient.NewOmnirpcClient(executorConfig.BaseOmnirpcURL, handler, omnirpcClient.WithCaptureReqRes()) } else { baseOmniRPCClient = omnirpcClient.NewOmnirpcClient(executorConfig.BaseOmnirpcURL, handler) } executor, err := executor.NewExecutor(ctx, executorConfig, executorDB, scribeClient, baseOmniRPCClient, handler) if err != nil { return fmt.Errorf("failed to create executor: %w", err) } g.Go(func() error { err := api.Start(ctx, uint16(c.Uint(metricsPortFlag.Name))) if err != nil { return fmt.Errorf("failed to start api: %w", err) } return nil }) g.Go(func() error { err := executor.Run(ctx) if err != nil { return fmt.Errorf("failed to run executor: %w", err) } return nil }) if err := g.Wait(); err != nil { return fmt.Errorf("failed to run executor: %w", err) } return nil }, }
ExecutorRunCommand runs the executor.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.