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

Use GetRequiredService instead of GetService to resolve jobs #24

Merged

Conversation

skarum
Copy link
Contributor

@skarum skarum commented Apr 19, 2024

As discussed in #23

Use GetRequiredService to resolve jobs.

Added tests + modified test that broke due to this change.

Copy link
Member

@linkdotnet linkdotnet left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for providing a fix and a test.

Can you add an entry to https://github.com/linkdotnet/NCronJob/blob/main/CHANGELOG.md as I use this file for releases.

tests/NCronJob.Tests/NCronJobIntegrationTests.cs Outdated Show resolved Hide resolved
@linkdotnet linkdotnet linked an issue Apr 19, 2024 that may be closed by this pull request
@skarum
Copy link
Contributor Author

skarum commented Apr 19, 2024

Can you add an entry to https://github.com/linkdotnet/NCronJob/blob/main/CHANGELOG.md as I use this file for releases.

Done

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Steven Giesel <stgiesel35@gmail.com>
@linkdotnet
Copy link
Member

Perfect! Thanks again. I will make a release 2.0.5 after the merge!

@linkdotnet linkdotnet merged commit 766adb1 into NCronJob-Dev:main Apr 19, 2024
3 checks passed
falvarez1 pushed a commit to falvarez1/NCronJob that referenced this pull request Apr 23, 2024
fix: Update CHANGELOG.md
Update Changelog.md for 2.0.5 release
feat: Use GetRequiredService instead of GetService to resolve jobs (NCronJob-Dev#24)
* Use GetRequiredService instead of GetService and added tests
* Removed redundant test
* Added entry in changelog
* Remove empty line in NCronJobIntegrationTests.cs

* Update CHANGELOG.md

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

feat: Added ISSUE template
falvarez1 pushed a commit to falvarez1/NCronJob that referenced this pull request Apr 23, 2024
…CronJob-Dev#24)

* Use GetRequiredService instead of GetService and added tests

* Removed redundant test

* Added entry in changelog

* Remove empty line in NCronJobIntegrationTests.cs

* Update CHANGELOG.md

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>
falvarez1 pushed a commit to falvarez1/NCronJob that referenced this pull request Apr 24, 2024
…CronJob-Dev#24)

* Use GetRequiredService instead of GetService and added tests

* Removed redundant test

* Added entry in changelog

* Remove empty line in NCronJobIntegrationTests.cs

* Update CHANGELOG.md

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>
falvarez1 pushed a commit to falvarez1/NCronJob that referenced this pull request Apr 24, 2024
…CronJob-Dev#24)

* Use GetRequiredService instead of GetService and added tests

* Removed redundant test

* Added entry in changelog

* Remove empty line in NCronJobIntegrationTests.cs

* Update CHANGELOG.md

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>
linkdotnet added a commit that referenced this pull request Apr 25, 2024
* Updated job scheduling and handling in NCronJob

A new `TestCancellationJob` class has been added to simulate a long-running job and handle job cancellation.
Everything was made to support async structures to better support error handling and cancellation support.
Added preliminary parallel execution support.

* enhanced the concurrency management, cleaned up logs

* ensure the Tasks are awaited properly to prevent them from persisting beyond the loop scope

* remove commented code

* This commit encompasses a broad range of improvements and organizational changes to job execution, retry logic, and concurrency management within the system:

- **Job and Retry Logic Refactoring:**
  - Moved `retryHandler` from `CronScheduler` to `JobExecutor` to centralize execution logic.
  - Consolidated all retry policy-related code into the new `RetryPolicies` folder.
  - Added `RetryPolicy` attributes with two strategies: exponential backoff and fixed interval.

- **Concurrency Enhancements:**
  - Introduced `SupportsConcurrency` attribute with a `MaxDegreeOfParallelism` parameter to finely control job execution.
  - Replaced `ConcurrencyConfig` class with `ConcurrencySettings`, incorporating a `MaxDegreeOfParallelism` property.
  - Updated `CronScheduler` and `NCronJobOptionBuilder` to utilize `ConcurrencySettings`.
  - Added preliminary support for priority-based queuing of jobs to improve execution efficiency.

- **Testing and Samples:**
  - Added new jobs in `NCronJobSample` project to showcase concurrency capabilities.
  - Updated sample project configuration, including removal of machine-specific settings and adding `ConcurrencySettings` to `.editorconfig`.
  - Enhanced `TestCancellationJob` to support a `MaxDegreeOfParallelism` of 10 and added multiple job instances for testing.

- **Project Structure and Cleanup:**
  - Moved job definition files into a dedicated `Jobs` folder.
  - Removed obsolete pragma directives and updated project settings to reflect new structure and focus.

- **Additional Features and Fixes:**
  - Added auto-detection of precision in `WithCronExpression` when the second parameter is omitted.
  - Added default values to `SupportsConcurrencyAttribute` to simplify job configuration.
  - Implemented thread safety in `CronScheduler.cs` to ensure reliable operation under concurrent access.
  - CronRegistry.RunInstantJob now has a void return type, aligning with expected behavior.

* This commit includes multiple refinements and fixes to the retry functionalities and associated tests. Key changes include:

- **Retry Attributes**: Minor updates to retry attributes to improve reliability.
- **Retry Logic Cleanup**: Cleaned up the retry code and added two new tests to ensure functionality.
- **Time Provider Fix**: Resolved issues in TimeProvider that affected tests, ensuring accurate time simulation.
- **Retry Issue Resolution**: Addressed specific bugs in the retry mechanisms that affected process stability.
- **Job Execution Context**: Changed JobExecutionContext to be an instance of Job Run rather than the Job itself, clarifying execution context.
- **Thread Safety in JobOptionBuilder**: Enhanced thread safety and added a test to verify concurrency handling in JobOptionBuilder.
- **CronExpression Tests**: Fixed previously broken tests related to CronExpressions and added additional tests to cover new cases.
- **optimize scheduler: use precomputed values for cron occurrence

* feat: Added ISSUE template

* feat: Use GetRequiredService instead of GetService to resolve jobs (#24)

* Use GetRequiredService instead of GetService and added tests

* Removed redundant test

* Added entry in changelog

* Remove empty line in NCronJobIntegrationTests.cs

* Update CHANGELOG.md

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>

* Update Changelog.md for 2.0.5 release

* fix: Update CHANGELOG.md

* This commit makes several improvements and bug fixes in the test infrastructure:

- **Test Fixes and Enhancements:**
  - Fixed all existing tests to ensure they are passing and accurately reflecting intended behavior.
  - Introduced a new version of `WaitForJobsOrTimeout` that allows time advancement for each run, facilitating more precise control over test timing and behavior.

* updated info

---------

Co-authored-by: Steven Giesel <stgiesel35@gmail.com>
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.

Exceptions in jobs are swallowed
2 participants