-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ServiceCollectionExtensions.cs
34 lines (30 loc) · 1.48 KB
/
ServiceCollectionExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using Microsoft.Extensions.Logging;
using WorkflowCore.Models;
using WorkflowCore.Providers.Redis.Services;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static WorkflowOptions UseRedisQueues(this WorkflowOptions options, string connectionString, string prefix)
{
options.UseQueueProvider(sp => new RedisQueueProvider(connectionString, prefix, sp.GetService<ILoggerFactory>()));
return options;
}
public static WorkflowOptions UseRedisLocking(this WorkflowOptions options, string connectionString, string prefix = null)
{
options.UseDistributedLockManager(sp => new RedisLockProvider(connectionString, prefix, sp.GetService<ILoggerFactory>()));
return options;
}
public static WorkflowOptions UseRedisPersistence(this WorkflowOptions options, string connectionString, string prefix, bool deleteComplete = false)
{
options.UsePersistence(sp => new RedisPersistenceProvider(connectionString, prefix, deleteComplete, sp.GetService<ILoggerFactory>()));
return options;
}
public static WorkflowOptions UseRedisEventHub(this WorkflowOptions options, string connectionString, string channel)
{
options.UseEventHub(sp => new RedisLifeCycleEventHub(connectionString, channel, sp.GetService<ILoggerFactory>()));
return options;
}
}
}