Skip to content

Commit fe7f106

Browse files
Merge commit 'ca7a7a3376b50facde4e85d258b53eb8e3064e92'
2 parents 4e6c65f + ca7a7a3 commit fe7f106

File tree

6 files changed

+125
-27
lines changed

6 files changed

+125
-27
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v2
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: v2
2+
name: buf.build/restatedev/service-protocol
3+
lint:
4+
use:
5+
- DEFAULT
6+
breaking:
7+
use:
8+
- FILE

sdk-core/src/main/service-protocol/dev/restate/service/discovery.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ enum ServiceDiscoveryProtocolVersion {
1919
SERVICE_DISCOVERY_PROTOCOL_VERSION_UNSPECIFIED = 0;
2020
// initial service discovery protocol version using endpoint_manifest_schema.json
2121
V1 = 1;
22+
// add custom metadata and documentation for services/handlers
23+
V2 = 2;
2224
}

sdk-core/src/main/service-protocol/dev/restate/service/protocol.proto

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ enum ServiceProtocolVersion {
2222
// Added
2323
// * Entry retry mechanism: ErrorMessage.next_retry_delay, StartMessage.retry_count_since_last_stored_entry and StartMessage.duration_since_last_stored_entry
2424
V2 = 2;
25+
// Added
26+
// * New entry to cancel invocations: CancelInvocationEntryMessage
27+
// * New entry to retrieve the invocation id: GetCallInvocationIdEntryMessage
28+
// * New field to set idempotency key for Call entries
29+
V3 = 3;
2530
}
2631

2732
// --- Core frames ---
@@ -313,6 +318,9 @@ message CallEntryMessage {
313318
// If this invocation has a key associated (e.g. for objects and workflows), then this key is filled in. Empty otherwise.
314319
string key = 5;
315320

321+
// If present, it must be non empty.
322+
optional string idempotency_key = 6;
323+
316324
oneof result {
317325
bytes value = 14;
318326
Failure failure = 15;
@@ -342,6 +350,9 @@ message OneWayCallEntryMessage {
342350
// If this invocation has a key associated (e.g. for objects and workflows), then this key is filled in. Empty otherwise.
343351
string key = 6;
344352

353+
// If present, it must be non empty.
354+
optional string idempotency_key = 7;
355+
345356
// Entry name
346357
string name = 12;
347358
}
@@ -383,17 +394,47 @@ message CompleteAwakeableEntryMessage {
383394
message RunEntryMessage {
384395
oneof result {
385396
bytes value = 14;
386-
dev.restate.service.protocol.Failure failure = 15;
397+
Failure failure = 15;
387398
};
388399

389400
// Entry name
390401
string name = 12;
391402
}
392403

404+
// Completable: No
405+
// Fallible: Yes
406+
// Type: 0x0C00 + 6
407+
message CancelInvocationEntryMessage {
408+
oneof target {
409+
// Target invocation id to cancel
410+
string invocation_id = 1;
411+
// Target index of the call/one way call journal entry in this journal.
412+
uint32 call_entry_index = 2;
413+
}
414+
415+
// Entry name
416+
string name = 12;
417+
}
418+
419+
// Completable: Yes
420+
// Fallible: Yes
421+
// Type: 0x0C00 + 7
422+
message GetCallInvocationIdEntryMessage {
423+
// Index of the call/one way call journal entry in this journal.
424+
uint32 call_entry_index = 1;
425+
426+
oneof result {
427+
string value = 14;
428+
Failure failure = 15;
429+
};
430+
431+
string name = 12;
432+
}
433+
393434
// --- Nested messages
394435

395436
// This failure object carries user visible errors,
396-
// e.g. invocation failure return value or failure result of an CallEntryMessage.
437+
// e.g. invocation failure return value or failure result of an InvokeEntryMessage.
397438
message Failure {
398439
// The code can be any HTTP status code, as described https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml.
399440
uint32 code = 1;

sdk-core/src/main/service-protocol/endpoint_manifest_schema.json

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"type": "object",
55
"title": "Endpoint",
6-
"description": "Restate endpoint manifest v1",
6+
"description": "Restate endpoint manifest v2",
77
"properties": {
88
"protocolMode": {
99
"title": "ProtocolMode",
10-
"enum": ["BIDI_STREAM", "REQUEST_RESPONSE"]
10+
"enum": [
11+
"BIDI_STREAM",
12+
"REQUEST_RESPONSE"
13+
]
1114
},
1215
"minProtocolVersion": {
1316
"type": "integer",
@@ -31,9 +34,17 @@
3134
"type": "string",
3235
"pattern": "^([a-zA-Z]|_[a-zA-Z0-9])[a-zA-Z0-9._-]*$"
3336
},
37+
"documentation": {
38+
"type": "string",
39+
"description": "Documentation for this service definition. No format is enforced, but generally Markdown is assumed."
40+
},
3441
"ty": {
3542
"title": "ServiceType",
36-
"enum": ["VIRTUAL_OBJECT", "SERVICE", "WORKFLOW"]
43+
"enum": [
44+
"VIRTUAL_OBJECT",
45+
"SERVICE",
46+
"WORKFLOW"
47+
]
3748
},
3849
"handlers": {
3950
"type": "array",
@@ -45,9 +56,17 @@
4556
"type": "string",
4657
"pattern": "^([a-zA-Z]|_[a-zA-Z0-9])[a-zA-Z0-9_]*$"
4758
},
59+
"documentation": {
60+
"type": "string",
61+
"description": "Documentation for this handler definition. No format is enforced, but generally Markdown is assumed."
62+
},
4863
"ty": {
4964
"title": "HandlerType",
50-
"enum": ["WORKFLOW", "EXCLUSIVE", "SHARED"],
65+
"enum": [
66+
"WORKFLOW",
67+
"EXCLUSIVE",
68+
"SHARED"
69+
],
5170
"description": "If unspecified, defaults to EXCLUSIVE for Virtual Object or WORKFLOW for Workflows. This should be unset for Services."
5271
},
5372
"input": {
@@ -122,18 +141,42 @@
122141
"setContentTypeIfEmpty": true
123142
}
124143
}
144+
},
145+
"metadata": {
146+
"type": "object",
147+
"description": "Custom metadata of this handler definition. This metadata is shown on the Admin API when querying the service/handler definition.",
148+
"additionalProperties": {
149+
"type": "string"
150+
}
125151
}
126152
},
127-
"required": ["name"],
153+
"required": [
154+
"name"
155+
],
128156
"additionalProperties": false
129157
}
158+
},
159+
"metadata": {
160+
"type": "object",
161+
"description": "Custom metadata of this service definition. This metadata is shown on the Admin API when querying the service definition.",
162+
"additionalProperties": {
163+
"type": "string"
164+
}
130165
}
131166
},
132-
"required": ["name", "ty", "handlers"],
167+
"required": [
168+
"name",
169+
"ty",
170+
"handlers"
171+
],
133172
"additionalProperties": false
134173
}
135174
}
136175
},
137-
"required": ["minProtocolVersion", "maxProtocolVersion", "services"],
176+
"required": [
177+
"minProtocolVersion",
178+
"maxProtocolVersion",
179+
"services"
180+
],
138181
"additionalProperties": false
139182
}

sdk-core/src/main/service-protocol/service-invocation-protocol.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,26 @@ used for observability purposes by Restate observability tools.
330330
The following tables describe the currently available journal entries. For more details, check the protobuf message
331331
descriptions in [`protocol.proto`](dev/restate/service/protocol.proto).
332332

333-
| Message | Type | Completable | Fallible | Description |
334-
| ------------------------------- | -------- | ----------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
335-
| `InputEntryMessage` | `0x0400` | No | No | Carries the invocation input message(s) of the invocation. |
336-
| `GetStateEntryMessage` | `0x0800` | Yes | No | Get the value of a service instance state key. |
337-
| `GetStateKeysEntryMessage` | `0x0804` | Yes | No | Get all the known state keys for this service instance. Note: the completion value for this message is a protobuf of type `GetStateKeysEntryMessage.StateKeys`. |
338-
| `SleepEntryMessage` | `0x0C00` | Yes | No | Initiate a timer that completes after the given time. |
339-
| `CallEntryMessage` | `0x0C01` | Yes | Yes | Invoke another Restate service. |
340-
| `AwakeableEntryMessage` | `0x0C03` | Yes | No | Arbitrary result container which can be completed from another service, given a specific id. See [Awakeable identifier](#awakeable-identifier) for more details. |
341-
| `OneWayCallEntryMessage` | `0x0C02` | No | Yes | Invoke another Restate service at the given time, without waiting for the response. |
342-
| `CompleteAwakeableEntryMessage` | `0x0C04` | No | Yes | Complete an `Awakeable`, given its id. See [Awakeable identifier](#awakeable-identifier) for more details. |
343-
| `OutputEntryMessage` | `0x0401` | No | No | Carries the invocation output message(s) or terminal failure of the invocation. |
344-
| `SetStateEntryMessage` | `0x0800` | No | No | Set the value of a service instance state key. |
345-
| `ClearStateEntryMessage` | `0x0801` | No | No | Clear the value of a service instance state key. |
346-
| `ClearAllStateEntryMessage` | `0x0802` | No | No | Clear all the values of the service instance state. |
347-
| `RunEntryMessage` | `0x0C05` | No | No | Run non-deterministic user provided code and persist the result. |
348-
| `GetPromiseEntryMessage` | `0x0808` | Yes | No | Get or wait the value of the given promise. If the value is not present yet, this entry will block waiting for the value. |
349-
| `PeekPromiseEntryMessage` | `0x0809` | Yes | No | Get the value of the given promise. If the value is not present, this entry completes immediately with empty completion. |
350-
| `CompletePromiseEntryMessage` | `0x080A` | Yes | No | Complete the given promise. If the promise was completed already, this entry completes with a failure. |
333+
| Message | Type | Completable | Fallible | Description |
334+
|-----------------------------------|----------|-------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
335+
| `InputEntryMessage` | `0x0400` | No | No | Carries the invocation input message(s) of the invocation. |
336+
| `GetStateEntryMessage` | `0x0800` | Yes | No | Get the value of a service instance state key. |
337+
| `GetStateKeysEntryMessage` | `0x0804` | Yes | No | Get all the known state keys for this service instance. Note: the completion value for this message is a protobuf of type `GetStateKeysEntryMessage.StateKeys`. |
338+
| `SleepEntryMessage` | `0x0C00` | Yes | No | Initiate a timer that completes after the given time. |
339+
| `CallEntryMessage` | `0x0C01` | Yes | Yes | Invoke another Restate service. |
340+
| `AwakeableEntryMessage` | `0x0C03` | Yes | No | Arbitrary result container which can be completed from another service, given a specific id. See [Awakeable identifier](#awakeable-identifier) for more details. |
341+
| `OneWayCallEntryMessage` | `0x0C02` | No | Yes | Invoke another Restate service at the given time, without waiting for the response. |
342+
| `CompleteAwakeableEntryMessage` | `0x0C04` | No | Yes | Complete an `Awakeable`, given its id. See [Awakeable identifier](#awakeable-identifier) for more details. |
343+
| `OutputEntryMessage` | `0x0401` | No | No | Carries the invocation output message(s) or terminal failure of the invocation. |
344+
| `SetStateEntryMessage` | `0x0800` | No | No | Set the value of a service instance state key. |
345+
| `ClearStateEntryMessage` | `0x0801` | No | No | Clear the value of a service instance state key. |
346+
| `ClearAllStateEntryMessage` | `0x0802` | No | No | Clear all the values of the service instance state. |
347+
| `RunEntryMessage` | `0x0C05` | No | No | Run non-deterministic user provided code and persist the result. |
348+
| `GetPromiseEntryMessage` | `0x0808` | Yes | No | Get or wait the value of the given promise. If the value is not present yet, this entry will block waiting for the value. |
349+
| `PeekPromiseEntryMessage` | `0x0809` | Yes | No | Get the value of the given promise. If the value is not present, this entry completes immediately with empty completion. |
350+
| `CompletePromiseEntryMessage` | `0x080A` | Yes | No | Complete the given promise. If the promise was completed already, this entry completes with a failure. |
351+
| `CancelInvocationEntryMessage` | `0x0C06` | No | Yes | Cancel the target invocation id or the target journal entry. |
352+
| `GetCallInvocationIdEntryMessage` | `0x0C07` | Yes | Yes | Get the invocation id of a previously created call/one way call. |
351353

352354
#### Awakeable identifier
353355

0 commit comments

Comments
 (0)