Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/NexusCancellation/Handler/HelloService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public class HelloService
context.StartWorkflowAsync(
(HelloHandlerWorkflow wf) => wf.RunAsync(input),
// Workflow IDs should typically be business meaningful IDs and are used to
// dedupe workflow starts. For this example, we're using the request ID
// allocated by Temporal when the caller workflow schedules the operation,
// this ID is guaranteed to be stable across retries of this operation.
new() { Id = context.HandlerContext.RequestId }));
}
// 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(' ', '-')}";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other examples, e.g. temporalio/samples-go#460, aren't going through the Name.Trim().Replace(...) jazz.

Are spaces allowed in Workflow IDs? If they are, then maybe that would just be overkill for the sample, if that type of sanitization isn't required? (Or if it is, maybe it should be added to the other examples?)

}
13 changes: 8 additions & 5 deletions src/NexusContextPropagation/Handler/HelloService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ public class HelloService
return context.StartWorkflowAsync(
(HelloHandlerWorkflow wf) => wf.RunAsync(input),
// Workflow IDs should typically be business meaningful IDs and are used to
// dedupe workflow starts. For this example, we're using the request ID
// allocated by Temporal when the caller workflow schedules the operation,
// this ID is guaranteed to be stable across retries of this operation.
new() { Id = context.HandlerContext.RequestId });
// 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(' ', '-')}";
}
13 changes: 8 additions & 5 deletions src/NexusMultiArg/Handler/HelloService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public class HelloService
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, we're using the request ID
// allocated by Temporal when the caller workflow schedules the operation,
// this ID is guaranteed to be stable across retries of this operation.
new() { Id = context.HandlerContext.RequestId }));
}
// 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(' ', '-')}";
}
13 changes: 8 additions & 5 deletions src/NexusSimple/Handler/HelloService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public class HelloService
context.StartWorkflowAsync(
(HelloHandlerWorkflow wf) => wf.RunAsync(input),
// Workflow IDs should typically be business meaningful IDs and are used to
// dedupe workflow starts. For this example, we're using the request ID
// allocated by Temporal when the caller workflow schedules the operation,
// this ID is guaranteed to be stable across retries of this operation.
new() { Id = context.HandlerContext.RequestId }));
}
// 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(' ', '-')}";
}
Loading