-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
60 lines (60 loc) · 1.79 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
using Conductor.Api;
using Conductor.Client.Extensions;
using Conductor.Definition;
using Conductor.Client.Worker;
using Conductor.Client;
using Conductor.Client.Models;
using Conductor.Client.Interfaces;
using Task = Conductor.Client.Models.Task;
using System.Text.Json;
using Conductor.Executor;
using Conductor.Client.Authentication;
using Conductor.Definition.TaskType;
using System;
using System.Threading;
using System.Threading.Tasks;
var configuration = new Configuration()
{
BasePath = "CONDUCTOR_SERVER_URL/api",
AuthenticationSettings = new OrkesAuthenticationSettings("YOUR_KEY", "YOUR_SECRET")
};
var host = WorkflowTaskHost.CreateWorkerHost(configuration, Microsoft.Extensions.Logging.LogLevel.Information, new SimpleWorker());
await host.StartAsync();
Thread.Sleep(TimeSpan.FromSeconds(100));
public class SimpleWorker : IWorkflowTask
{
public string TaskType
{
get;
}
public WorkflowTaskExecutorConfiguration WorkerSettings
{
get;
}
public SimpleWorker(string taskType = "simple")
{
TaskType = taskType;
WorkerSettings = new WorkflowTaskExecutorConfiguration();
}
public async System.Threading.Tasks.Task<TaskResult> Execute(Task task, CancellationToken token =
default)
{
return await System.Threading.Tasks.Task.Run(() =>
{
var result = task.Completed();
string outputString = "Hello world";
result.OutputData = new Dictionary<string, object>
{
{
"result",
outputString += " " + string.Join(" ", [task.InputData["key"]])
}
};
return result;
});
}
public TaskResult Execute(Task task)
{
throw new NotImplementedException();
}
}