forked from danielgerlag/workflow-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceCollectionExtensions.cs
More file actions
36 lines (32 loc) · 1.56 KB
/
Copy pathServiceCollectionExtensions.cs
File metadata and controls
36 lines (32 loc) · 1.56 KB
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
35
36
using Microsoft.Extensions.Logging;
using WorkflowCore.Models;
using WorkflowCore.Providers.Azure.Interface;
using WorkflowCore.Providers.Azure.Services;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static WorkflowOptions UseAzureSynchronization(this WorkflowOptions options, string connectionString)
{
options.UseQueueProvider(sp => new AzureStorageQueueProvider(connectionString, sp.GetService<ILoggerFactory>()));
options.UseDistributedLockManager(sp => new AzureLockManager(connectionString, sp.GetService<ILoggerFactory>()));
return options;
}
public static WorkflowOptions UseAzureServiceBusEventHub(
this WorkflowOptions options,
string connectionString,
string topicName,
string subscriptionName)
{
options.UseEventHub(sp => new ServiceBusLifeCycleEventHub(
connectionString, topicName, subscriptionName, sp.GetService<ILoggerFactory>()));
return options;
}
public static WorkflowOptions UseCosmosDbPersistence(this WorkflowOptions options, string connectionString, string databaseId)
{
options.Services.AddTransient<ICosmosDbProvisioner>(sp => new CosmosDbProvisioner(connectionString, sp.GetService<ILoggerFactory>()));
options.UsePersistence(sp => new CosmosDbPersistenceProvider(connectionString, databaseId, sp.GetService<ICosmosDbProvisioner>()));
return options;
}
}
}