mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-25 22:01:16 +00:00
refactoring, WiP
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Consul;
|
||||
using Hangfire;
|
||||
using Hangfire.Redis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@@ -25,6 +24,12 @@ namespace MalwareMultiScan.Shared.Extensions
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Hangfire with Redis storage.
|
||||
/// </summary>
|
||||
/// <param name="services">Service collection.</param>
|
||||
/// <param name="configuration">Configuration.</param>
|
||||
/// <param name="queues">Queue names.</param>
|
||||
public static void AddHangfire(this IServiceCollection services,
|
||||
IConfiguration configuration, params string[] queues)
|
||||
{
|
||||
@@ -34,7 +39,19 @@ namespace MalwareMultiScan.Shared.Extensions
|
||||
services.AddHangfire(options =>
|
||||
options.UseRedisStorage(configuration.GetValue<string>("REDIS_ADDRESS")));
|
||||
|
||||
services.AddHangfireServer(options => options.Queues = queues);
|
||||
services.AddHangfireServer(options =>
|
||||
{
|
||||
options.Queues = queues;
|
||||
|
||||
options.ServerTimeout = TimeSpan.FromSeconds(30);
|
||||
options.HeartbeatInterval = TimeSpan.FromSeconds(5);
|
||||
options.ServerCheckInterval = TimeSpan.FromSeconds(15);
|
||||
|
||||
var workerCount = configuration.GetValue<int>("WORKER_COUNT");
|
||||
|
||||
if (workerCount > 0)
|
||||
options.WorkerCount = workerCount;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user