|
| 1 | +// The MIT License |
| 2 | +// |
| 3 | +// Copyright (c) 2023 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.nexus.v1; |
| 24 | + |
| 25 | +option go_package = "go.temporal.io/api/nexus/v1;nexus"; |
| 26 | +option java_package = "io.temporal.api.nexus.v1"; |
| 27 | +option java_multiple_files = true; |
| 28 | +option java_outer_classname = "MessageProto"; |
| 29 | +option ruby_package = "Temporalio::Api::Nexus::V1"; |
| 30 | +option csharp_namespace = "Temporalio.Api.Nexus.V1"; |
| 31 | + |
| 32 | +import "google/protobuf/any.proto"; |
| 33 | +import "google/protobuf/struct.proto"; |
| 34 | +import "temporal/api/common/v1/message.proto"; |
| 35 | + |
| 36 | +// A general purpose failure message. |
| 37 | +// See: https://github.com/nexus-rpc/api/blob/main/SPEC.md#failure |
| 38 | +message Failure { |
| 39 | + string message = 1; |
| 40 | + map<string, string> metadata = 2; |
| 41 | + google.protobuf.Value details = 3; |
| 42 | +} |
| 43 | + |
| 44 | +message HandlerError { |
| 45 | + // See https://github.com/nexus-rpc/api/blob/main/SPEC.md#predefined-handler-errors. |
| 46 | + string error_type = 1; |
| 47 | + Failure failure = 2; |
| 48 | +} |
| 49 | + |
| 50 | +message UnsuccessfulOperationError { |
| 51 | + // See https://github.com/nexus-rpc/api/blob/main/SPEC.md#operationinfo. |
| 52 | + string operation_state = 1; |
| 53 | + Failure failure = 2; |
| 54 | +} |
| 55 | + |
| 56 | +// A request to start an operation. |
| 57 | +message StartOperationRequest { |
| 58 | + // Type of operation to start. |
| 59 | + string operation = 1; |
| 60 | + // A request ID that can be used as an idempotentency key. |
| 61 | + string request_id = 2; |
| 62 | + // Callback URL to call upon completion if the started operation is async. |
| 63 | + string callback = 3; |
| 64 | + // Full request body from the incoming HTTP request. |
| 65 | + temporal.api.common.v1.Payload payload = 4; |
| 66 | +} |
| 67 | + |
| 68 | +// A request to cancel an operation. |
| 69 | +message CancelOperationRequest { |
| 70 | + // Type of operation to cancel. |
| 71 | + string operation = 1; |
| 72 | + // Operation ID as originally generated by a Handler. |
| 73 | + string operation_id = 2; |
| 74 | +} |
| 75 | + |
| 76 | +// A Nexus request. |
| 77 | +message Request { |
| 78 | + // Headers extracted from the original request in the Temporal frontend. |
| 79 | + // When using Nexus over HTTP, this includes the request's HTTP headers ignoring multiple values. |
| 80 | + map<string, string> header = 1; |
| 81 | + oneof variant { |
| 82 | + StartOperationRequest start_operation = 2; |
| 83 | + CancelOperationRequest cancel_operation = 3; |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +// Response variant for StartOperationRequest. |
| 88 | +message StartOperationResponse { |
| 89 | + // An operation completed successfully. |
| 90 | + message Sync { |
| 91 | + temporal.api.common.v1.Payload payload = 1; |
| 92 | + } |
| 93 | + |
| 94 | + // The operation will complete asynchronously. |
| 95 | + // The returned ID can be used to reference this operation. |
| 96 | + message Async { |
| 97 | + string operation_id = 1; |
| 98 | + } |
| 99 | + |
| 100 | + oneof variant { |
| 101 | + Sync sync_success = 1; |
| 102 | + Async async_success = 2; |
| 103 | + // The operation completed unsuccessfully (failed or canceled). |
| 104 | + UnsuccessfulOperationError operation_error = 3; |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +// Response variant for CancelOperationRequest. |
| 109 | +message CancelOperationResponse { |
| 110 | +} |
| 111 | + |
| 112 | +// A response indicating that the handler has successfully processed a request. |
| 113 | +message Response { |
| 114 | + // Variant must correlate to the corresponding Request's variant. |
| 115 | + oneof variant { |
| 116 | + StartOperationResponse start_operation = 1; |
| 117 | + CancelOperationResponse cancel_operation = 2; |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +// A binding from a service name to namespace, task queue, and metadata for dispatching incoming Nexus requests. |
| 122 | +message IncomingService { |
| 123 | + // Data version for this service. Must match current version on update or set to 0 to create a new service. |
| 124 | + int64 version = 1; |
| 125 | + // Service name, unique for this cluster. |
| 126 | + // The service name is used to address this service. |
| 127 | + // By default, when using Nexus over HTTP, the service name is matched against the base URL path. |
| 128 | + // E.g. the URL /my-service would match a service named "my-service". |
| 129 | + // The name can contain any characters and is escaped when matched against a URL. |
| 130 | + string name = 2; |
| 131 | + // Namespace to route requests to. |
| 132 | + string namespace = 3; |
| 133 | + // Task queue to route requests to. |
| 134 | + string task_queue = 4; |
| 135 | + // Generic service metadata that is available to the server's authorizer. |
| 136 | + map<string, google.protobuf.Any> metadata = 5; |
| 137 | +} |
| 138 | + |
0 commit comments