1k-validators-be icon indicating copy to clipboard operation
1k-validators-be copied to clipboard

Scorekeeper Refactoring 2/4

Open vovacha opened this issue 1 year ago • 0 comments

First part https://github.com/w3f/1k-validators-be/pull/2934

Current PR changes:

  • Localize behavior by bringing cron job initialization into the Job class.
  • Remove cron/StartCronJobs/, cron/SetupCronJobs/.
  • Remove the JobNames enum.
  • Add enums: JobStatus, JobEvent, JobKey.
  • Clean up job modules.
  • Add new tests.

Comments:

  • There is almost no need for the events now, since CronJob is a part of the Job class. The only event that makes sense is the JobEvent.Progress event. Job chaining is something to check; that could be a reason for having other event handlers.
  • There is no consistency in the logging strategy when working with labels and logging levels.
  • There is a redundancy in the exception handling in the job functions.
  • Not sure if it's the correct behavior. jobFinished event will immediately overwrite jobErrored status here https://github.com/w3f/1k-validators-be/blob/master/packages/common/src/scorekeeper/jobs/cron/SetupCronJob.ts#L63-L73

Impact:

  • Package common
  • Package scorekeeper-status-ui

Potential next steps (to be discussed):

  • [ ] Scorekeeper 1. First part of refactoring.
  • [ ] Scorekeeper 2. Current PR.
  • [ ] Scorekeeper 3. Add DB queries to store job status.
  • [ ] Gateway. Update views to retrieve job statuses from the DB.
  • [ ] Gateway. Remove Scorekeeper dependency.
  • [ ] Core. Update Gateway initialization without Scorekeeper.
  • [ ] Scorekeeper 4. Remove status updates via events and eliminate public interfaces related to the Gateway.
  • [ ] Gateway. Reduce abstraction layers and code duplication in controllers.
  • [ ] Gateway. Refactor dynamic routes (e.g., onlyHealth flag).
  • [ ] Deployment Update. Update deployment scripts to run services separately: Scorekeeper, Gateway, and Telemetry.

vovacha avatar May 19 '24 21:05 vovacha