Skip to content

Automatically generates the recurring job registration code using source generators

License

Notifications You must be signed in to change notification settings

IeuanWalker/Hangfire.RecurringJob

Repository files navigation

Hangfire.RecurringJob Nuget Nuget

License: MIT Build

Automatically generates the recurring job registration code using source generators

How to use it?

  1. Install the NuGet package into your project.
Install-Package IeuanWalker.Hangfire.RecurringJob
  1. Add the RecurringJob attribute to a class, and create an Execute() method.
[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();
	}
}
  1. 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.

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

image

About

Automatically generates the recurring job registration code using source generators

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages