Skip to content

Commit

Permalink
Add option to manually enable indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Nov 25, 2024
1 parent 1ef7cea commit ad1e1f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pkg/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type DbOptions struct {
WaitForDB time.Duration `long:"wait-for" env:"XMTPD_DB_WAIT_FOR" description:"wait for DB on start, up to specified duration"`
}

type IndexerOptions struct {
Enable bool `long:"enable" env:"XMTPD_INDEXER_ENABLE" description:"Enable the indexer"`
}

// MetricsOptions are settings used to start a prometheus server
type MetricsOptions struct {
Enable bool `long:"enable" env:"XMTPD_METRICS_ENABLE" description:"Enable the metrics server"`
Expand Down Expand Up @@ -101,6 +105,7 @@ type ServerOptions struct {
Contracts ContractsOptions `group:"Contracts Options" namespace:"contracts"`
DB DbOptions `group:"Database Options" namespace:"db"`
Log LogOptions `group:"Log Options" namespace:"log"`
Indexer IndexerOptions `group:"Indexer Options" namespace:"indexer"`
Metrics MetricsOptions `group:"Metrics Options" namespace:"metrics"`
MlsValidation MlsValidationOptions `group:"MLS Validation Options" namespace:"mls-validation"`
Payer PayerOptions `group:"Payer Options" namespace:"payer"`
Expand Down
19 changes: 11 additions & 8 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@ func NewReplicationServer(
return nil, err
}

s.indx = indexer.NewIndexer(ctx, log)
err = s.indx.StartIndexer(
s.writerDB,
options.Contracts,
validationService,
)
if err != nil {
return nil, err
if options.Indexer.Enable {
s.indx = indexer.NewIndexer(ctx, log)
err = s.indx.StartIndexer(
s.writerDB,
options.Contracts,
validationService,
)

if err != nil {
return nil, err
}
}

serviceRegistrationFunc := func(grpcServer *grpc.Server) error {
Expand Down

0 comments on commit ad1e1f8

Please sign in to comment.