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

Add AbstractPeriodicJob to the bg job lib #263

Merged
merged 12 commits into from
Aug 7, 2024
Merged

Conversation

kibertoad
Copy link
Collaborator

Changes

Make the AbstractPeriodicJob reusable across libraries

Checklist

  • Apply one of following labels; major, minor, patch or skip-release
  • I've updated the documentation, or no changes were necessary
  • I've updated the tests, or no changes were necessary

Comment on lines 47 to 50
/**
* If true, the job will log when it starts and finishes.
*/
shouldLogExecution?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we always log start and finish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since this job is happening on a regular cadence, log might not always be useful, so there is a way to remove the noise

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see and it makes sense, but if I am not wrong it is false by default, I would expect to have it true but no strong opinion from my side

Comment on lines 156 to 158
protected abstract processInternal(executionUuid: string): Promise<unknown>

public async process(executorId: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

On AbstractBackgroundJobProcessor we use these names but in the other direction, should we follow the same approach? (process for the abstract method and processInternal for the private one)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure. note that there needs to be a public entry point that toad-scheduler task can invoke. would you call that processInternal?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see, sorry for the misunderstanding, wondering if we can make the method private and createTask receive the method to call, something like:

createTask(logger: CommonLogger, jobId: string, method: (execId: string) => Promise<void>): AsyncTask

But I see createTask is exposed, so maybe it is not a good idea 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I would probably keep it as-is, not sure that tinkering with this part would decrease complexity significantly

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I am fine with it, my only point was not allowing to directly call that method or override it

@kibertoad kibertoad merged commit dbf8c60 into main Aug 7, 2024
4 checks passed
@kibertoad kibertoad deleted the feat/abstract-periodic-job branch August 7, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants