diff --git a/await-signals/README.md b/await-signals/README.md index dfb7f6f0..aa9e6d9c 100644 --- a/await-signals/README.md +++ b/await-signals/README.md @@ -1,14 +1,14 @@ * The sample demonstrates how to deal with multiple signals that can come out of order and require actions * if a certain signal not received in a specified time interval. -This specific sample receives three signals: Signal1, Signal2, Signal3. They have to be processed in the +This specific sample receives three signals: Signal1, Signal2, Signal3. They have to be processed in sequential order, but they can be received out of order. There are two timeouts to enforce. The first one is the maximum time between signals. The second limits the total time since the first signal received. -A naive implementation of such use case would use a single loop that contains a Selector to listen on three -signals and a timer. Something like: +A naive implementation would use a single loop that contains a Selector to listen on three signals and a timer. +Something like: for { selector := workflow.NewSelector(ctx) diff --git a/nexus/handler/app.go b/nexus/handler/app.go index d1fa6be8..bf11f888 100644 --- a/nexus/handler/app.go +++ b/nexus/handler/app.go @@ -14,25 +14,30 @@ import ( "github.com/temporalio/samples-go/nexus/service" ) -// NewSyncOperation is a meant for exposing simple RPC handlers. -var EchoOperation = temporalnexus.NewSyncOperation(service.EchoOperationName, func(ctx context.Context, c client.Client, input service.EchoInput, options nexus.StartOperationOptions) (service.EchoOutput, error) { - // The method is provided with an SDK client that can be used for arbitrary calls such as signaling, querying, - // and listing workflows but implementations are free to make arbitrary calls to other services or databases, or - // perform simple computations such as this one. - return service.EchoOutput(input), nil -}) +// NewSyncOperation is meant for exposing simple RPC handlers. +var EchoOperation = temporalnexus.NewSyncOperation( + service.EchoOperationName, + func(ctx context.Context, c client.Client, input service.EchoInput, options nexus.StartOperationOptions) (service.EchoOutput, error) { + // The method is provided with an SDK client that can be used for arbitrary calls such as signaling, querying, + // and listing workflows but implementations are free to make arbitrary calls to other services or databases, or + // perform simple computations such as this one. + return service.EchoOutput(input), nil + }) // Use the NewWorkflowRunOperation constructor, which is the easiest way to expose a workflow as an operation. // See alternatives at https://pkg.go.dev/go.temporal.io/sdk/temporalnexus. -var HelloOperation = temporalnexus.NewWorkflowRunOperation(service.HelloOperationName, HelloHandlerWorkflow, func(ctx context.Context, input service.HelloInput, options nexus.StartOperationOptions) (client.StartWorkflowOptions, error) { - return client.StartWorkflowOptions{ - // 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. - ID: options.RequestID, - // Task queue defaults to the task queue this operation is handled on. - }, nil -}) +var HelloOperation = temporalnexus.NewWorkflowRunOperation( + service.HelloOperationName, + HelloHandlerWorkflow, + func(ctx context.Context, input service.HelloInput, options nexus.StartOperationOptions) (client.StartWorkflowOptions, error) { + return client.StartWorkflowOptions{ + // 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. + ID: options.RequestID, + // Task queue defaults to the task queue this operation is handled on. + }, nil + }) func HelloHandlerWorkflow(_ workflow.Context, input service.HelloInput) (service.HelloOutput, error) { switch input.Language { @@ -49,4 +54,5 @@ func HelloHandlerWorkflow(_ workflow.Context, input service.HelloInput) (service } return service.HelloOutput{}, fmt.Errorf("unsupported language %q", input.Language) } -// @@@SNIPEND \ No newline at end of file + +// @@@SNIPEND