diff --git a/dev/restate/services.proto b/dev/restate/services.proto index bed0a86..4cd1380 100644 --- a/dev/restate/services.proto +++ b/dev/restate/services.proto @@ -25,19 +25,27 @@ service Ingress { // Invoke a service and don't wait for the response. // It is guaranteed that the service will be invoked after this method returns. rpc Invoke(InvokeRequest) returns (InvokeResponse); + + // Invoke a service in an idempotent fashion. + // If already invoked, this will return the cached response. + // The response will be cleaned up after a retention period. + rpc IdempotentInvoke(IdempotentInvokeRequest) returns (IdempotentInvokeResponse); } message InvokeRequest { // Fully qualified name of the service, e.g. `counter.Counter` string service = 1; + // Method name of the service to invoke, e.g. `Add` string method = 2; + // Argument of the invocation. - // When executing requests to the ingress using Protobuf, - // this field must contain the serialized Protobuf matching the argument type of the target method. - // When executing requests to the ingress using JSON, - // this field must contain the JSON object representing the argument type of the target method. - bytes argument = 3; + // You can pass the invocation argument either as protobuf or as JSON. + // In case of JSON, the argument will be automatically transcoded to protobuf. + oneof argument { + bytes pb = 3; + google.protobuf.Struct json = 4 [json_name = "argument"]; + } } message InvokeResponse { @@ -46,6 +54,44 @@ message InvokeResponse { string id = 1; } +message IdempotentInvokeRequest { + // Idempotency id. + string idempotency_id = 1; + + // Fully qualified name of the service, e.g. `counter.Counter` + string service = 2; + + // Method name of the service to invoke, e.g. `Add` + string method = 3; + + // Argument of the invocation. + // You can pass the invocation argument either as protobuf or as JSON. + // In case of JSON, the argument will be automatically transcoded to protobuf. + oneof argument { + bytes pb = 4; + google.protobuf.Struct json = 5 [json_name = "argument"]; + } + + // Retention period for the response in seconds. + // After the invocation completes, the response will be persisted for the given duration. + // Afterwards, the system will cleanup the response and treats any subsequent invocation with same id as new. + // + // If not set, 30 minutes will be used as retention period. + uint32 retention_period_sec = 6; +} + +message IdempotentInvokeResponse { + // Invocation response. + // The response will be provided in the same format used for the request. + oneof response { + bytes pb = 1; + google.protobuf.Struct json = 2 [json_name = "response"]; + } + + // Timestamp of the response expiry time in RFC3339. + string expiry_time = 3; +} + service Awakeables { // Resolve an Awakeable with a result value. rpc Resolve(ResolveAwakeableRequest) returns (google.protobuf.Empty);