Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laget-se/laget.quartz
A generic implementation of Quartz, an open-source job scheduling system for .NET...
https://github.com/laget-se/laget.quartz
nuget quartz
Last synced: about 1 month ago
JSON representation
A generic implementation of Quartz, an open-source job scheduling system for .NET...
- Host: GitHub
- URL: https://github.com/laget-se/laget.quartz
- Owner: laget-se
- License: apache-2.0
- Created: 2021-05-13T04:20:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T07:05:27.000Z (3 months ago)
- Last Synced: 2024-10-23T10:10:23.042Z (3 months ago)
- Topics: nuget, quartz
- Language: C#
- Homepage:
- Size: 146 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laget.Quartz
A generic implementation of Quartz, an open-source job scheduling system for .NET.
## Configuration
> This implementation requires `Autofac` since this is the Inversion of Control container of our choosing.### Usage
#### Simple
> This will by default register all jobs from the calling assembly.
```c#
await Host.CreateDefaultBuilder()
.ConfigureContainer((context, builder) =>
{
builder.RegisterQuartzJobs();
builder.RegisterQuartzService();
})
.ConfigureServices((context, services) =>
{
services.AddQuartzService();
})
.Build()
.RunAsync();
```### Advanced
```c#
await Host.CreateDefaultBuilder()
.ConfigureContainer((context, builder) =>
{
builder.RegisterQuartzJobs(_ =>
{
_.Assembly("name");
_.Register();
_.TheCallingAssembly();
_.TheEntryAssembly();
_.TheExecutingAssembly();
});
builder.RegisterQuartzService(new NameValueCollection
{
{ "quartz.serializer.type", "binary" },
{ "quartz.scheduler.instanceName", "ThisIsAnInstance" },
{ "quartz.jobStore.type", "Quartz.Simpl.RAMJobStore, Quartz" },
{ "quartz.threadPool.threadCount", "4" }
});
})
.ConfigureServices((context, services) =>
{
services.AddQuartzService();
})
.Build()
.RunAsync();
```This is the advanced and more customizable way to register your mappers
* `Assembly("name");`
> This will register the job from the assembly, will load assembly via the name provided using `System.Reflection`, that inherits from `Job (laget.Quartz.Job)`.
* `Register();`
> This will register the job that inherits from `Job (laget.Quartz.Job)`.
* `TheCallingAssembly();`
> This will register the job from the calling assembly that inherits from `Job (laget.Quartz.Job)`.
* `TheEntryAssembly();`
> This will register the job from the entry assembly that inherits from `Job (laget.Quartz.Job)`.
* `TheExecutingAssembly();`
> This will register the job from the executing assembly that inherits from `Job (laget.Quartz.Job)`.> For a full configuration reference, please take a look at [here!](https://www.quartz-scheduler.net/documentation/quartz-3.x/configuration/reference.html#main-configuration)
### Modules
```c#
await Host.CreateDefaultBuilder()
.ConfigureContainer((context, builder) =>
{
builder.RegisterQuartzJobs(_ =>
{
_.RegisterModule();
});
builder.RegisterQuartzService();
})
.ConfigureServices((context, services) =>
{
services.AddQuartzService();
})
.Build()
.RunAsync();
```
```c#
public class OrderModule : Module
{
public override void Configure(IRegistrator registrator)
{
registrator.Register();
registrator.Register();
}
}
```#### Job
```c#
[DisallowConcurrentExecution]
public class SomeJob : laget.Quartz.Job
{
private readonly ISomeService _someService;// We need this empty constructor as it's used when scheduling the job
public SomeJob()
{
}public SomeJob(ISomeService someService)
{
_someService = someService;
}public override async Task ExecuteJob(IJobExecutionContext context)
{
// Do some stuff here!
}public override ITrigger Trigger => TriggerBuilder
.Create()
.StartNow()
.WithIdentity(Name, Group)
.WithSimpleSchedule(x => x
.WithInterval(Interval)
.WithMisfireHandlingInstructionIgnoreMisfires()
.RepeatForever()
)
.Build();private static TimeSpan Interval => TimeSpan.FromSeconds(60);
public override string Group => "Group";
public override string Name => nameof(SomeJob);
}
```