-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
66 lines (53 loc) · 2.2 KB
/
Program.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using QuickStart.Dotnet;
using LittleHorse.Sdk;
using LittleHorse.Sdk.Common.Proto;
using LittleHorse.Sdk.Worker;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
public class Program
{
private static ServiceProvider? _serviceProvider;
private static void SetupApplication()
{
_serviceProvider = new ServiceCollection()
.AddLogging(config =>
{
config.AddConsole();
config.SetMinimumLevel(LogLevel.Debug);
})
.BuildServiceProvider();
}
private static LHConfig GetLHConfig(ILoggerFactory loggerFactory)
{
var config = new LHConfig(loggerFactory);
string filePath = Path.Combine(Directory.GetCurrentDirectory(), ".config/littlehorse.config");
if (File.Exists(filePath))
config = new LHConfig(filePath, loggerFactory);
return config;
}
static void Main(string[] args)
{
SetupApplication();
if (_serviceProvider != null)
{
var loggerFactory = _serviceProvider.GetRequiredService<ILoggerFactory>();
var config = GetLHConfig(loggerFactory);
var request = new PutExternalEventDefRequest
{
Name = "identity-verified"
};
config.GetGrpcClientInstance().PutExternalEventDef(request);
var tasks = new KnowYourCustomerTasks();
var identityVerificationWorker = new LHTaskWorker<KnowYourCustomerTasks>(tasks, "verify-identity", config);
var notifyCustomerVerifiedWorker = new LHTaskWorker<KnowYourCustomerTasks>(tasks, "notify-customer-verified", config);
var notifyCustomerNotVerifiedWorker = new LHTaskWorker<KnowYourCustomerTasks>(tasks, "notify-customer-not-verified", config);
identityVerificationWorker.RegisterTaskDef();
notifyCustomerVerifiedWorker.RegisterTaskDef();
notifyCustomerNotVerifiedWorker.RegisterTaskDef();
Thread.Sleep(1000);
identityVerificationWorker.Start();
notifyCustomerVerifiedWorker.Start();
notifyCustomerNotVerifiedWorker.Start();
}
}
}