-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathServiceCollectionExtensions.cs
More file actions
56 lines (46 loc) · 1.95 KB
/
ServiceCollectionExtensions.cs
File metadata and controls
56 lines (46 loc) · 1.95 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Dtmcli;
using DtmCommon;
using Dtmgrpc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
namespace Dtmworkflow
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddDtmWorkflow(this IServiceCollection services, Action<DtmOptions> setupAction)
{
if (setupAction == null)
{
throw new ArgumentNullException(nameof(setupAction));
}
services.AddDtmcli(setupAction);
services.AddDtmGrpc(setupAction);
services.TryAddSingleton<IWorkflowFactory, WorkflowFactory>();
services.TryAddSingleton<WorkflowGlobalTransaction>();
// AddHttpClient(services);
return services;
}
public static IServiceCollection AddDtmWorkflow(this IServiceCollection services, IConfiguration configuration, string sectionName = "dtm")
{
services.AddDtmcli(configuration, sectionName);
services.AddDtmGrpc(configuration, sectionName);
services.TryAddSingleton<IWorkflowFactory, WorkflowFactory>();
services.TryAddSingleton<WorkflowGlobalTransaction>();
// AddHttpClient(services);
return services;
}
// private static void AddHttpClient(IServiceCollection services /*, DtmOptions options*/)
// {
// services.AddHttpClient(Dtmcli.Constant.WorkflowBranchClientHttpName, client =>
// {
// // TODO DtmOptions
// // client.Timeout = TimeSpan.FromMilliseconds(options.BranchTimeout);
// }).AddHttpMessageHandler<WorkflowHttpInterceptor>();
//
// // TODO how to inject workflow instance?
// services.AddTransient<WorkflowHttpInterceptor>();
// }
}
}