-
Notifications
You must be signed in to change notification settings - Fork 0
BackgroundTasks: Configuration
Scheduler implementation is moved out to separate implementation. As if right not only Hangfire scheduler is supported. You need to install Itmo.Dev.Platform.BackgroundTasks.Hangfire
package and call UseHangfireScheduling
extension method (as shown below) to register it.
Storage configuration for Persistence and Scheduler is moved out to separate implementations. As if right now only Postgres database is supported. You need to install Itmo.Dev.Platform.BackgroundTasks.Postgres
and Itmo.Dev.Platform.BackgroundTasks.Hanfgire.Postgres
packages and call UsePostgresPersistence
and UsePostgresJobStorage
extensions method (as shown below) to register them.
collection.AddPlatformBackgroundTasks(
tasks => tasks
.UsePostgresPersistence(
builder => builder.BindConfiguration("Infrastructure:BackgroundTasks:Persistence"))
.ConfigureScheduling(
builder => builder.BindConfiguration("Infrastructure:BackgroundTasks:Scheduling"))
.UseHangfireScheduling(
hangfire => hangfire
.ConfigureOptions(
builder => builder.BindConfiguration("Infrastructure:BackgroundTasks:Scheduling:Hangfire"))
.UsePostgresJobStorage())
.ConfigureExecution(configuration)
.AddStateMachine());
{
"SchemaName": string
}
- SchemaName
Name of a PostgreSQL schema to store background task data
"Infrastructure": {
"BackgroundTasks": {
"Persistence": {
"SchemaName": "background_tasks"
}
}
}
This configuration section used to configure library scheduler.
{
"BatchSize": int,
"PollingDelay": timespan
}
- BatchSize
Number of tasks fetched per enqueuing run - PollingDelay
Delay between enqueuing runs
"Infrastructure": {
"BackgroundTasks": {
"Scheduling": {
"BatchSize": 10,
"PollingDelay": "00:00:05"
}
}
}
This configuration section used to configure Hangfire scheduler, these parameters are passed directly to Hangfire.
{
"CancellationCheckInterval": timespan,
"SchedulerRetryCount": int,
"SchedulerRetryDelays": [int],
"SchedulerWorkerCount": int
}
- CancellationCheckInterval
Delay between cancellation checks - SchedulerRetryCount
Count of retries that hangfire will do, before marking task failed - SchedulerRetryDelays
Delay between hangfire retries, index corresponds to retry number - SchedulerWorkerCount
Count of Hangfire workers
"Infrastructure": {
"BackgroundTasks": {
"Scheduling": {
"Hangfire": {
"SchedulerRetryCount": 10,
"SchedulerWorkerCount": 2,
"SchedulerRetryDelays": [60, 120, 180],
"SchedulerWorkerCount": 1
}
}
}
}
{
"MaxRetryCount": int
}
- MaxRetryCount
Count of enqueueing retries for before task is moved into failed state
"Infrastructure": {
"BackgroundTasks": {
"Execution": {
"MaxRetryCount": 5
}
}
}