-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support async handling and add CronJob status tracking (#894)
## Description This PR improves async handling in the CronJob class and adds status tracking functionality. - Modified the `fireOnTick()` method to return a Promise for better async callback handling - Added an `isCallbackRunning` flag to track the running state of CronJob instances - Updated the test suite to use the new async behavior and track the job's running state - Added `waitForCompletion` functionality to the `job.stop()` method - waits for running jobs to complete before executing the `onComplete` callback During test case writing, I encountered a type error with sinon. To resolve this, added `sinon.restore()` to the `afterEach` block. Reference: https://stackoverflow.com/questions/73232999/sinon-cant-install-fake-timers-twice-on-the-same-global-object <img width="811" alt="스크린샷 2024-09-03 오후 7 10 58" src="https://github.com/user-attachments/assets/b87deee7-14b2-4407-8fea-a1cb469ef44b"> ## Related Issue Closes #713 Closes #556 ## Motivation and Context These changes allow the CronJob class to handle asynchronous callbacks more effectively and provide a way to track the running state of jobs. ## How Has This Been Tested? - Updated existing test suite to verify the new async behavior - Adjusted test timeouts to use the `tickAsync` method - Added new test cases to check for proper waiting of running callbacks before stopping ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: - [x] My code follows the code style of this project. - [x] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I have added tests to cover my changes. - [x] All new and existing tests passed. - [ ] If my change introduces a breaking change, I have added a `!` after the type/scope in the title (see the Conventional Commits standard). --------- Co-authored-by: Brandon der Blätter <[email protected]>
- Loading branch information
1 parent
94465ae
commit b58fb6b
Showing
4 changed files
with
251 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.