-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
packages/app/background-jobs-common/src/periodic-jobs/AbstractPeriodicJob.ts
Outdated
Show resolved
Hide resolved
packages/app/background-jobs-common/src/periodic-jobs/AbstractPeriodicJob.ts
Outdated
Show resolved
Hide resolved
/** | ||
* If true, the job will log when it starts and finishes. | ||
*/ | ||
shouldLogExecution?: boolean |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
packages/app/background-jobs-common/src/periodic-jobs/AbstractPeriodicJob.ts
Outdated
Show resolved
Hide resolved
packages/app/background-jobs-common/src/periodic-jobs/AbstractPeriodicJob.ts
Show resolved
Hide resolved
protected abstract processInternal(executionUuid: string): Promise<unknown> | ||
|
||
public async process(executorId: string) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Changes
Make the AbstractPeriodicJob reusable across libraries
Checklist
major
,minor
,patch
orskip-release