-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathHelloService.cs
More file actions
25 lines (22 loc) · 1.29 KB
/
HelloService.cs
File metadata and controls
25 lines (22 loc) · 1.29 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
namespace TemporalioSamples.NexusMultiArg.Handler;
using NexusRpc.Handlers;
using Temporalio.Nexus;
[NexusServiceHandler(typeof(IHelloService))]
public class HelloService
{
[NexusOperationHandler]
public IOperationHandler<IHelloService.HelloInput, IHelloService.HelloOutput> SayHello() =>
// This Nexus service operation is backed by a workflow run. For this sample, we are
// altering the parameters to the workflow (in this case expanding to two parameters).
WorkflowRunOperationHandler.FromHandleFactory(
(WorkflowRunOperationContext context, IHelloService.HelloInput input) =>
context.StartWorkflowAsync(
(HelloHandlerWorkflow wf) => wf.RunAsync(input.Language, input.Name),
// Workflow IDs should typically be business meaningful IDs and are used to
// dedupe workflow starts. For this example, use a business ID derived from
// the greeting input so repeated operations for the same name and language
// resolve to the same workflow.
new() { Id = GetHelloWorkflowId(input) }));
private static string GetHelloWorkflowId(IHelloService.HelloInput input) =>
$"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}";
}