Skip to content

Commit c43384d

Browse files
authored
Update Nexus Incoming Service CRUD to match Cloud API (#372)
1 parent 905672f commit c43384d

File tree

6 files changed

+150
-52
lines changed

6 files changed

+150
-52
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL=/bin/bash -o pipefail
2+
13
$(VERBOSE).SILENT:
24
############################# Main targets #############################
35
ci-build: install proto http-api-docs

buf.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ breaking:
1111
- WIRE_JSON
1212
ignore:
1313
- google
14-
# Uncomment this after https://github.com/temporalio/api/pull/362 is merged
14+
# Uncomment this after https://github.com/temporalio/api/pull/372 has been merged.
1515
- temporal/api/operatorservice/v1/request_response.proto
16+
- temporal/api/operatorservice/v1/service.proto
17+
- temporal/api/nexus/v1/message.proto
1618
lint:
1719
use:
1820
- DEFAULT

openapi/openapiv2.json

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,20 +3982,20 @@
39823982
}
39833983
}
39843984
},
3985-
"v1CreateNexusOutgoingServiceResponse": {
3985+
"v1CreateNexusIncomingServiceResponse": {
39863986
"type": "object",
39873987
"properties": {
39883988
"service": {
3989-
"$ref": "#/definitions/v1OutgoingService",
3989+
"$ref": "#/definitions/v1IncomingService",
39903990
"description": "Data post acceptance. Can be used to issue additional updates to this record."
39913991
}
39923992
}
39933993
},
3994-
"v1CreateOrUpdateNexusIncomingServiceResponse": {
3994+
"v1CreateNexusOutgoingServiceResponse": {
39953995
"type": "object",
39963996
"properties": {
39973997
"service": {
3998-
"$ref": "#/definitions/v1IncomingService",
3998+
"$ref": "#/definitions/v1OutgoingService",
39993999
"description": "Data post acceptance. Can be used to issue additional updates to this record."
40004000
}
40014001
}
@@ -4740,11 +4740,39 @@
47404740
"version": {
47414741
"type": "string",
47424742
"format": "int64",
4743-
"description": "Data version for this service, incremented for every update issued via the CreateOrUpdateNexusIncomingService\nAPI."
4743+
"description": "Data version for this service, incremented for every update issued via the UpdateNexusIncomingService API."
47444744
},
4745+
"id": {
4746+
"type": "string",
4747+
"description": "Unique server-generated service ID."
4748+
},
4749+
"spec": {
4750+
"$ref": "#/definitions/v1IncomingServiceSpec",
4751+
"description": "Spec for the service."
4752+
},
4753+
"createdTime": {
4754+
"type": "string",
4755+
"format": "date-time",
4756+
"description": "The date and time when the service was created."
4757+
},
4758+
"lastModifiedTime": {
4759+
"type": "string",
4760+
"format": "date-time",
4761+
"description": "The date and time when the service was last modified.\nWill not be set if the service has never been modified."
4762+
},
4763+
"urlPrefix": {
4764+
"type": "string",
4765+
"description": "Server exposed URL prefix for invocation of operations on this service.\nThis doesn't include the protocol, hostname or port as the server does not know how it should be accessed\npublicly. The URL is stable in the face of service renames."
4766+
}
4767+
},
4768+
"description": "A cluster-global binding from a service ID to namespace, task queue, and metadata for dispatching incoming Nexus\nrequests."
4769+
},
4770+
"v1IncomingServiceSpec": {
4771+
"type": "object",
4772+
"properties": {
47454773
"name": {
47464774
"type": "string",
4747-
"description": "Service name, unique for this cluster.\nThe service name is used to address this service.\nBy default, when using Nexus over HTTP, the service name is matched against the base URL path.\nE.g. the URL /api/v1/services/my-service/ would match a service named \"my-service\".\nThe name must match `[a-zA-Z_][a-zA-Z0-9_]*`."
4775+
"description": "Service name, unique for this cluster. Must match `[a-zA-Z_][a-zA-Z0-9_]*`."
47484776
},
47494777
"namespace": {
47504778
"type": "string",
@@ -4762,7 +4790,7 @@
47624790
"description": "Generic service metadata that is available to the server's authorizer."
47634791
}
47644792
},
4765-
"description": "A binding from a service name to namespace, task queue, and metadata for dispatching incoming Nexus requests."
4793+
"description": "Contains mutable fields for an IncomingService."
47664794
},
47674795
"v1IndexedValueType": {
47684796
"type": "string",
@@ -5329,6 +5357,16 @@
53295357
"spec": {
53305358
"$ref": "#/definitions/v1OutgoingServiceSpec",
53315359
"description": "Spec for the service."
5360+
},
5361+
"createdTime": {
5362+
"type": "string",
5363+
"format": "date-time",
5364+
"description": "The date and time when the service was created."
5365+
},
5366+
"lastModifiedTime": {
5367+
"type": "string",
5368+
"format": "date-time",
5369+
"description": "The date and time when the service was last modified.\nWill not be set if the service has never been modified."
53325370
}
53335371
},
53345372
"description": "A per-namespace binding from service name to URL that is used by the service to invoke Nexus requests that are\ninitiated by workflows."
@@ -7404,6 +7442,15 @@
74047442
}
74057443
}
74067444
},
7445+
"v1UpdateNexusIncomingServiceResponse": {
7446+
"type": "object",
7447+
"properties": {
7448+
"service": {
7449+
"$ref": "#/definitions/v1IncomingService",
7450+
"description": "Data post acceptance. Can be used to issue additional updates to this record."
7451+
}
7452+
}
7453+
},
74077454
"v1UpdateNexusOutgoingServiceResponse": {
74087455
"type": "object",
74097456
"properties": {

temporal/api/nexus/v1/message.proto

Lines changed: 44 additions & 13 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/any.proto";
3333
import "google/protobuf/struct.proto";
34+
import "google/protobuf/timestamp.proto";
3435
import "temporal/api/common/v1/message.proto";
3536

3637
// A general purpose failure message.
@@ -118,26 +119,45 @@ message Response {
118119
}
119120
}
120121

121-
// A binding from a service name to namespace, task queue, and metadata for dispatching incoming Nexus requests.
122+
// A cluster-global binding from a service ID to namespace, task queue, and metadata for dispatching incoming Nexus
123+
// requests.
122124
message IncomingService {
123-
// Data version for this service, incremented for every update issued via the CreateOrUpdateNexusIncomingService
124-
// API.
125+
// Data version for this service, incremented for every update issued via the UpdateNexusIncomingService API.
125126
int64 version = 1;
126-
// Service name, unique for this cluster.
127-
// The service name is used to address this service.
128-
// By default, when using Nexus over HTTP, the service name is matched against the base URL path.
129-
// E.g. the URL /api/v1/services/my-service/ would match a service named "my-service".
130-
// The name must match `[a-zA-Z_][a-zA-Z0-9_]*`.
131-
string name = 2;
127+
// Unique server-generated service ID.
128+
string id = 2;
129+
// Spec for the service.
130+
IncomingServiceSpec spec = 3;
131+
132+
// The date and time when the service was created.
133+
// (-- api-linter: core::0142::time-field-names=disabled
134+
// aip.dev/not-precedent: Not following linter rules. --)
135+
google.protobuf.Timestamp created_time = 4;
136+
137+
// The date and time when the service was last modified.
138+
// Will not be set if the service has never been modified.
139+
// (-- api-linter: core::0142::time-field-names=disabled
140+
// aip.dev/not-precedent: Not following linter rules. --)
141+
google.protobuf.Timestamp last_modified_time = 5;
142+
143+
// Server exposed URL prefix for invocation of operations on this service.
144+
// This doesn't include the protocol, hostname or port as the server does not know how it should be accessed
145+
// publicly. The URL is stable in the face of service renames.
146+
string url_prefix = 6;
147+
}
148+
149+
// Contains mutable fields for an IncomingService.
150+
message IncomingServiceSpec {
151+
// Service name, unique for this cluster. Must match `[a-zA-Z_][a-zA-Z0-9_]*`.
152+
string name = 1;
132153
// Namespace to route requests to.
133-
string namespace = 3;
154+
string namespace = 2;
134155
// Task queue to route requests to.
135-
string task_queue = 4;
156+
string task_queue = 3;
136157
// Generic service metadata that is available to the server's authorizer.
137-
map<string, google.protobuf.Any> metadata = 5;
158+
map<string, google.protobuf.Any> metadata = 4;
138159
}
139160

140-
141161
// A per-namespace binding from service name to URL that is used by the service to invoke Nexus requests that are
142162
// initiated by workflows.
143163
message OutgoingService {
@@ -147,6 +167,17 @@ message OutgoingService {
147167
string name = 2;
148168
// Spec for the service.
149169
OutgoingServiceSpec spec = 3;
170+
171+
// The date and time when the service was created.
172+
// (-- api-linter: core::0142::time-field-names=disabled
173+
// aip.dev/not-precedent: Not following linter rules. --)
174+
google.protobuf.Timestamp created_time = 4;
175+
176+
// The date and time when the service was last modified.
177+
// Will not be set if the service has never been modified.
178+
// (-- api-linter: core::0142::time-field-names=disabled
179+
// aip.dev/not-precedent: Not following linter rules. --)
180+
google.protobuf.Timestamp last_modified_time = 5;
150181
}
151182

152183
// Contains mutable fields for an OutgoingService.

temporal/api/operatorservice/v1/request_response.proto

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

3434
import "temporal/api/enums/v1/common.proto";
3535
import "temporal/api/nexus/v1/message.proto";
36-
import "google/protobuf/any.proto";
3736
import "google/protobuf/duration.proto";
3837

3938
// (-- Search Attribute --)
@@ -128,39 +127,43 @@ message ClusterMetadata {
128127
}
129128

130129
message GetNexusIncomingServiceRequest {
131-
// Name of service to retrieve.
132-
string name = 1;
130+
// Server-generated unique service ID.
131+
string id = 1;
133132
}
134133

135134
message GetNexusIncomingServiceResponse {
136135
temporal.api.nexus.v1.IncomingService service = 1;
137136
}
138137

139-
message CreateOrUpdateNexusIncomingServiceRequest {
140-
// Data version for this service. Must match current version on update or set to 0 to create a new service.
141-
int64 version = 1;
142-
// Service name, unique for this cluster.
143-
// The service name is used to address this service.
144-
// By default, when using Nexus over HTTP, the service name is matched against the base URL path.
145-
// E.g. the URL /api/v1/services/my-service/ would match a service named "my-service".
146-
// The name must match `[a-zA-Z_][a-zA-Z0-9_]*`.
147-
string name = 2;
148-
// Namespace to route requests to.
149-
string target_namespace = 3;
150-
// Task queue to route requests to.
151-
string target_task_queue = 4;
152-
// Generic service metadata that is available to the server's authorizer.
153-
map<string, google.protobuf.Any> metadata = 5;
138+
message CreateNexusIncomingServiceRequest {
139+
// Service definition to create.
140+
temporal.api.nexus.v1.IncomingServiceSpec spec = 1;
141+
}
142+
143+
message CreateNexusIncomingServiceResponse {
144+
// Data post acceptance. Can be used to issue additional updates to this record.
145+
temporal.api.nexus.v1.IncomingService service = 1;
154146
}
155147

156-
message CreateOrUpdateNexusIncomingServiceResponse {
148+
message UpdateNexusIncomingServiceRequest {
149+
// Server-generated unique service ID.
150+
string id = 1;
151+
// Data version for this service. Must match current version.
152+
int64 version = 2;
153+
154+
temporal.api.nexus.v1.IncomingServiceSpec spec = 3;
155+
}
156+
157+
message UpdateNexusIncomingServiceResponse {
157158
// Data post acceptance. Can be used to issue additional updates to this record.
158159
temporal.api.nexus.v1.IncomingService service = 1;
159160
}
160161

161162
message DeleteNexusIncomingServiceRequest {
162-
// Name of service to delete.
163-
string name = 1;
163+
// Server-generated unique service ID.
164+
string id = 1;
165+
// Data version for this service. Must match current version.
166+
int64 version = 2;
164167
}
165168

166169
message DeleteNexusIncomingServiceResponse {
@@ -172,6 +175,10 @@ message ListNexusIncomingServicesRequest {
172175
// response, the token will be empty if there's no other page.
173176
// Note: the last page may be empty if the total number of services registered is a multiple of the page size.
174177
bytes next_page_token = 2;
178+
// Name of the incoming service to filter on - optional. Specifying this will result in zero or one results.
179+
// (-- api-linter: core::203::field-behavior-required=disabled
180+
// aip.dev/not-precedent: Not following linter rules. --)
181+
string name = 3;
175182
}
176183

177184
message ListNexusIncomingServicesResponse {

temporal/api/operatorservice/v1/service.proto

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,32 @@ service OperatorService {
7878
rpc ListClusters(ListClustersRequest) returns (ListClustersResponse) {
7979
}
8080

81-
// Get a registered incoming Nexus service by name. The returned version can be used for optimistic updates.
81+
// Get a registered incoming Nexus service by ID. The returned version can be used for optimistic updates.
8282
rpc GetNexusIncomingService(GetNexusIncomingServiceRequest) returns (GetNexusIncomingServiceResponse) {
8383
}
8484

85-
// Optimistically create or update a Nexus service based on provided version.
86-
// To update an existing service, get the current service record via the `GetNexusIncomingService` API, modify it
87-
// and submit to this API.
88-
// Set version to 0 to create a new service.
89-
// Returns the updated service with the updated version, which can be used for subsequent updates.
90-
rpc CreateOrUpdateNexusIncomingService(CreateOrUpdateNexusIncomingServiceRequest) returns (CreateOrUpdateNexusIncomingServiceResponse) {
85+
// Create a Nexus service. This will fail if a service with the same name already exists in the namespace with a
86+
// status of ALREADY_EXISTS.
87+
// Returns the created service with its initial version. You may use this version for subsequent updates.
88+
rpc CreateNexusIncomingService(CreateNexusIncomingServiceRequest) returns (CreateNexusIncomingServiceResponse) {
89+
}
90+
91+
// Optimistically update a Nexus service based on provided version as obtained via the
92+
// `GetNexusIncomingService` or `ListNexusOutgoingServicesResponse` APIs. This will fail with a status of
93+
// FAILED_PRECONDITION if the version does not match.
94+
// Returns the updated service with its updated version. You may use this version for subsequent updates. You don't
95+
// need to increment the version yourself. The server will increment the version for you after each update.
96+
rpc UpdateNexusIncomingService(UpdateNexusIncomingServiceRequest) returns (UpdateNexusIncomingServiceResponse) {
9197
}
9298

93-
// Delete an incoming Nexus service by name.
99+
// Delete an incoming Nexus service by ID.
94100
rpc DeleteNexusIncomingService(DeleteNexusIncomingServiceRequest) returns (DeleteNexusIncomingServiceResponse) {
95101
}
96102

97-
// List all Nexus incoming services in the cluster. Use next_page_token in the response for pagination.
103+
// List all Nexus incoming services for the cluster, sorted by service ID in ascending order. Set page_token in the
104+
// request to the next_page_token field of the previous response to get the next page of results. An empty
105+
// next_page_token indicates that there are no more results. During pagination, a newly added service with an ID
106+
// lexicographically earlier than the previous page's last service name may be missed.
98107
rpc ListNexusIncomingServices(ListNexusIncomingServicesRequest) returns (ListNexusIncomingServicesResponse) {
99108
}
100109

@@ -105,7 +114,7 @@ service OperatorService {
105114

106115
// Create a Nexus service. This will fail if a service with the same name already exists in the namespace with a
107116
// status of ALREADY_EXISTS.
108-
// Returns the updated service with its initial version. You may use this version for subsequent updates. You don't
117+
// Returns the created service with its initial version. You may use this version for subsequent updates. You don't
109118
// need to increment the version yourself. The server will increment the version for you after each update.
110119
rpc CreateNexusOutgoingService(CreateNexusOutgoingServiceRequest) returns (CreateNexusOutgoingServiceResponse) {
111120
}

0 commit comments

Comments
 (0)