https://github.com/IeuanWalker/Hangfire.RecurringJob
Automatically generates the recurring job registration code using source generators
https://github.com/IeuanWalker/Hangfire.RecurringJob
hangfire recurring-jobs source-generator
Last synced: 21 days ago
JSON representation
Automatically generates the recurring job registration code using source generators
- Host: GitHub
- URL: https://github.com/IeuanWalker/Hangfire.RecurringJob
- Owner: IeuanWalker
- License: mit
- Created: 2023-09-27T15:59:50.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-19T07:45:09.000Z (about 1 year ago)
- Last Synced: 2025-04-01T23:44:37.280Z (about 1 month ago)
- Topics: hangfire, recurring-jobs, source-generator
- Language: C#
- Homepage:
- Size: 85 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/IeuanWalker/Hangfire.RecurringJob
- csharp-source-generators - Hangfire.RecurringJob -   - Automatically generates the recurring job registration code. (Source Generators / Other)
README
# Hangfire.RecurringJob [](https://www.nuget.org/packages/IeuanWalker.Hangfire.RecurringJob) [](https://www.nuget.org/packages/IeuanWalker.Hangfire.RecurringJob)
[](https://opensource.org/licenses/MIT)
[](https://github.com/IeuanWalker/Hangfire.RecurringJob/actions/workflows/build.yml)Automatically generates the recurring job registration code using source generators
## How to use it?
1. Install the [NuGet package](https://www.nuget.org/packages/IeuanWalker.Hangfire.RecurringJob) into your project.
```
Install-Package IeuanWalker.Hangfire.RecurringJob
```2. Add the `RecurringJob` attribute to a class, and create an `Execute()` method.
```csharp
[RecurringJob]
public class RecurringJob1
{
public Task Execute()
{
throw new NotImplementedException();
}
}[RecurringJob("* * * *")]
public class RecurringJob2
{
public void Execute()
{
throw new NotImplementedException();
}
}[RecurringJob("* * * *", "Priority")]
public class RecurringJob3
{
public void Execute()
{
throw new NotImplementedException();
}
}[RecurringJob]
[RecurringJob("*/5 * * * *", "GMT", "Priority", "DataRetention")]
public class RecurringJob4
{
public void Execute()
{
throw new NotImplementedException();
}
}
```
3. Register the recurring jobs
> Once a `RecurringJob` attribute has been added to a class in your project an extension method for `IApplicationBuilder` will automatically be created.
> The extension method name convention is AddRecurringJobsFrom + your assembly name.
```csharp
app.AddRecurringJobsFromExampleProject();
```## Example
Here is an example of what it looks like in use -
> Left is the example code, and right is the generated code