Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor startup #37

Merged
merged 11 commits into from
Dec 20, 2024
Merged

feat: refactor startup #37

merged 11 commits into from
Dec 20, 2024

Conversation

tcar121293
Copy link
Contributor

Description

  • Refactor the indexer startup in a way that allows the indexer to be run in a single container
  • Add domainID to logger metadata

),
}),
];
export function getLogger(domainID?: string): winston.Logger {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to still have the singleton logger and then if you need a label create:

export function createChildLogger(labels: Record<string, any/string>): winston.Logger {
  return logger.child({
    labels: {
      ...logger.defaultMeta.labels,
      label: label
    }
  });
}

This way if you go deeper in the stack and add more labels you just create a child of the one that already has the labels.
Also, you don't have to call getLogger() everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually i think we don't need createChildLogger. We can just do logger.child({additionalOptions})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

src/main.ts Outdated
envVars.domainMetadata.rpcUrl,
);
break;
for (const domain of sharedConfig.domains) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a separate env variable that defines which domains you want.
ENV_DOMAINS for example and then you can specify which to index.
So if we want to skip some domain or separate them by containers we can easily do it just by changing the config slightly.

start-prod.sh Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
mj52951
mj52951 previously approved these changes Dec 18, 2024
src/main.ts Outdated Show resolved Hide resolved
Signed-off-by: tcar <[email protected]>
@tcar121293 tcar121293 merged commit e757f5c into main Dec 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants