From be1edaaca988eeae422dcde1aafd4b863651688d Mon Sep 17 00:00:00 2001 From: Konst Date: Tue, 27 Aug 2024 15:55:42 +0300 Subject: [PATCH] Added Indexer inheritance from modules.BaseModule --- build/dipdup.yml | 2 +- cmd/metadata/indexer.go | 42 +++++++---------------------------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/build/dipdup.yml b/build/dipdup.yml index 639e231..6017210 100644 --- a/build/dipdup.yml +++ b/build/dipdup.yml @@ -115,7 +115,7 @@ database: port: ${POSTGRES_PORT:-5432} user: ${POSTGRES_USER:-dipdup} password: ${POSTGRES_PASSWORD:-changeme} - database: ${POSTGRES_DB:-dipdup} + database: ${POSTGRES_DB:-starknet_metadata} hasura: url: http://${HASURA_HOST:-hasura}:${HASURA_PORT:-8080} diff --git a/cmd/metadata/indexer.go b/cmd/metadata/indexer.go index 0342589..210db57 100644 --- a/cmd/metadata/indexer.go +++ b/cmd/metadata/indexer.go @@ -24,11 +24,14 @@ var ( // input name const ( - InputName = "input" + InputName = "input" + OutputName = "output" ) // Indexer - type Indexer struct { + modules.BaseModule + client *grpc.Client storage postgres.Storage input *modules.Input @@ -61,6 +64,9 @@ func NewIndexer(cfg Metadata, datasources map[string]config.DataSource, pg postg indexer.filler = filler indexer.receiver = NewReceiver(cfg.Receiver, pg.TokenMetadata, ipfsNode) + indexer.CreateInput(InputName) + indexer.CreateOutput(OutputName) + return indexer, nil } @@ -238,40 +244,6 @@ func (indexer *Indexer) Output(name string) (*modules.Output, error) { return nil, errors.Wrap(modules.ErrUnknownOutput, name) } -// AttachTo - attach input to output -func (indexer *Indexer) AttachTo(outputModule modules.Module, outputName, inputName string) error { - outputChannel, err := outputModule.Output(outputName) - if err != nil { - return err - } - - input, err := indexer.Input(inputName) - if err != nil { - return err - } - - outputChannel.Attach(input) - return nil -} - -// MustInput - -func (indexer *Indexer) MustInput(name string) *modules.Input { - input, err := indexer.Input(name) - if err != nil { - panic(err) - } - return input -} - -// MustOutput - -func (indexer *Indexer) MustOutput(name string) *modules.Output { - output, err := indexer.Output(name) - if err != nil { - panic(err) - } - return output -} - // Unsubscribe - func (indexer *Indexer) Unsubscribe(ctx context.Context) error { log.Info().Uint64("id", indexer.subId).Msg("unsubscribing...")