Skip to content

Commit 6795d69

Browse files
authored
Add HandlerErrorRetryBehavior (#551)
1 parent 2106c7e commit 6795d69

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

openapi/openapiv2.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8967,6 +8967,10 @@
89678967
},
89688968
"failure": {
89698969
"$ref": "#/definitions/apinexusv1Failure"
8970+
},
8971+
"retryBehavior": {
8972+
"$ref": "#/definitions/v1NexusHandlerErrorRetryBehavior",
8973+
"description": "Retry behavior, defaults to the retry behavior of the error type as defined in the spec."
89708974
}
89718975
}
89728976
},
@@ -9756,12 +9760,26 @@
97569760
},
97579761
"description": "NewWorkflowExecutionInfo is a shared message that encapsulates all the\nrequired arguments to starting a workflow in different contexts."
97589762
},
9763+
"v1NexusHandlerErrorRetryBehavior": {
9764+
"type": "string",
9765+
"enum": [
9766+
"NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_UNSPECIFIED",
9767+
"NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_RETRYABLE",
9768+
"NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_NON_RETRYABLE"
9769+
],
9770+
"default": "NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_UNSPECIFIED",
9771+
"description": "NexusHandlerErrorRetryBehavior allows nexus handlers to explicity set the retry behavior of a HandlerError. If not\nspecified, retry behavior is determined from the error type. For example internal errors are not retryable by default\nunless specified otherwise.\n\n - NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_RETRYABLE: A handler error is explicitly marked as retryable.\n - NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_NON_RETRYABLE: A handler error is explicitly marked as non-retryable."
9772+
},
97599773
"v1NexusHandlerFailureInfo": {
97609774
"type": "object",
97619775
"properties": {
97629776
"type": {
97639777
"type": "string",
97649778
"description": "The Nexus error type as defined in the spec:\nhttps://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors."
9779+
},
9780+
"retryBehavior": {
9781+
"$ref": "#/definitions/v1NexusHandlerErrorRetryBehavior",
9782+
"description": "Retry behavior, defaults to the retry behavior of the error type as defined in the spec."
97659783
}
97669784
}
97679785
},

openapi/openapiv3.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7277,6 +7277,14 @@ components:
72777277
description: |-
72787278
The Nexus error type as defined in the spec:
72797279
https://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors.
7280+
retryBehavior:
7281+
enum:
7282+
- NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_UNSPECIFIED
7283+
- NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_RETRYABLE
7284+
- NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_NON_RETRYABLE
7285+
type: string
7286+
description: Retry behavior, defaults to the retry behavior of the error type as defined in the spec.
7287+
format: enum
72807288
NexusOperationCancelRequestedEventAttributes:
72817289
type: object
72827290
properties:

temporal/api/enums/v1/nexus.proto

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// The MIT License
2+
//
3+
// Copyright (c) 2025 Temporal Technologies Inc. All rights reserved.
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
syntax = "proto3";
22+
23+
package temporal.api.enums.v1;
24+
25+
option go_package = "go.temporal.io/api/enums/v1;enums";
26+
option java_package = "io.temporal.api.enums.v1";
27+
option java_multiple_files = true;
28+
option java_outer_classname = "NexusProto";
29+
option ruby_package = "Temporalio::Api::Enums::V1";
30+
option csharp_namespace = "Temporalio.Api.Enums.V1";
31+
32+
// NexusHandlerErrorRetryBehavior allows nexus handlers to explicity set the retry behavior of a HandlerError. If not
33+
// specified, retry behavior is determined from the error type. For example internal errors are not retryable by default
34+
// unless specified otherwise.
35+
enum NexusHandlerErrorRetryBehavior {
36+
NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_UNSPECIFIED = 0;
37+
// A handler error is explicitly marked as retryable.
38+
NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_RETRYABLE = 1;
39+
// A handler error is explicitly marked as non-retryable.
40+
NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_NON_RETRYABLE = 2;
41+
}
42+

temporal/api/failure/v1/message.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ option csharp_namespace = "Temporalio.Api.Failure.V1";
3333

3434
import "temporal/api/common/v1/message.proto";
3535
import "temporal/api/enums/v1/workflow.proto";
36+
import "temporal/api/enums/v1/nexus.proto";
3637

3738
import "google/protobuf/duration.proto";
3839

@@ -106,6 +107,8 @@ message NexusHandlerFailureInfo {
106107
// The Nexus error type as defined in the spec:
107108
// https://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors.
108109
string type = 1;
110+
// Retry behavior, defaults to the retry behavior of the error type as defined in the spec.
111+
temporal.api.enums.v1.NexusHandlerErrorRetryBehavior retry_behavior = 2;
109112
}
110113

111114
message Failure {

temporal/api/nexus/v1/message.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ option csharp_namespace = "Temporalio.Api.Nexus.V1";
3131

3232
import "google/protobuf/timestamp.proto";
3333
import "temporal/api/common/v1/message.proto";
34+
import "temporal/api/enums/v1/nexus.proto";
3435

3536
// A general purpose failure message.
3637
// See: https://github.com/nexus-rpc/api/blob/main/SPEC.md#failure
@@ -45,6 +46,8 @@ message HandlerError {
4546
// See https://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors.
4647
string error_type = 1;
4748
Failure failure = 2;
49+
// Retry behavior, defaults to the retry behavior of the error type as defined in the spec.
50+
temporal.api.enums.v1.NexusHandlerErrorRetryBehavior retry_behavior = 3;
4851
}
4952

5053
message UnsuccessfulOperationError {

0 commit comments

Comments
 (0)