29 lines
952 B
C#
29 lines
952 B
C#
using Hangfire;
|
|
using Hangfire.Redis.StackExchange;
|
|
using YuanXuan.IM.Common.Configs;
|
|
|
|
namespace YuanXuan.IM.Api.Hangfire
|
|
{
|
|
public static class WskService
|
|
{
|
|
public static void AddWskService(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
if (services==null)
|
|
{
|
|
throw new ArgumentNullException(nameof(services));
|
|
}
|
|
services.AddHostedService<InitialHangfireService>();
|
|
|
|
var HangfireConfig = configuration.GetSection("Hangfire").Get<HangFireSettings>();
|
|
HangFireSettings.hangfireStorage = new RedisStorage(HangfireConfig.ConnectionString, new RedisStorageOptions
|
|
{
|
|
|
|
Db = HangfireConfig.Db,
|
|
FetchTimeout = TimeSpan.FromSeconds(30),
|
|
|
|
});
|
|
services.AddHangfire(config => config.UseStorage(HangFireSettings.hangfireStorage));
|
|
}
|
|
}
|
|
}
|