From e8781abc7f5f731366cd994e8a25dc89659c9fa7 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 May 2020 11:11:42 +0200 Subject: [PATCH] WIP of protocol changes to both accommodate Metadata but also clean up protocols --- protocols/protocol/cloudstate/crdt.proto | 2 + protocols/protocol/cloudstate/entity.proto | 54 ++++++++++++------- protocols/protocol/cloudstate/function.proto | 9 ++-- .../proto/cloudstate/proxy/statemanager.proto | 7 +-- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/protocols/protocol/cloudstate/crdt.proto b/protocols/protocol/cloudstate/crdt.proto index 5c8135d78..b8b9ab42b 100644 --- a/protocols/protocol/cloudstate/crdt.proto +++ b/protocols/protocol/cloudstate/crdt.proto @@ -326,6 +326,8 @@ message CrdtReply { // and a CrdtStreamCancelled message will be sent if the stream is cancelled (though // not if the a CrdtStreamedMessage ends the stream first). bool streamed = 6; + + repeated Metadata metadata = 7; // FIXME Should we rely on client_action Reply's metadata instead? } message CrdtStateAction { diff --git a/protocols/protocol/cloudstate/entity.proto b/protocols/protocol/cloudstate/entity.proto index 671b93826..aee8f37bf 100644 --- a/protocols/protocol/cloudstate/entity.proto +++ b/protocols/protocol/cloudstate/entity.proto @@ -31,16 +31,18 @@ option go_package = "cloudstate/protocol"; message Reply { // The reply payload google.protobuf.Any payload = 1; + + // The reply metadata + repeated Metadata metadata = 2; } // Forwards handling of this request to another entity. message Forward { // The name of the service to forward to. string service_name = 1; - // The name of the command. - string command_name = 2; - // The payload. - google.protobuf.Any payload = 3; + + // The call to forward to that service + Call call = 2; } // An action for the client @@ -64,15 +66,8 @@ message SideEffect { // The name of the service to perform the side effect on. string service_name = 1; - // The name of the command. - string command_name = 2; - - // The payload of the command. - google.protobuf.Any payload = 3; - - // Whether this side effect should be performed synchronously, ie, before the reply is eventually - // sent, or not. - bool synchronous = 4; + // The call to make on the service + Call call = 2; } // A command. For each command received, a reply must be sent with a matching command id. @@ -81,17 +76,36 @@ message Command { // The ID of the entity. string entity_id = 1; - // A command id. + // A command identifier, to be used for correlation and deduplication purposes int64 id = 2; - // Command name - string name = 3; + // The Call to make on the entity + Call call = 3; +} + +// A Call describes what endpoint, what payload, and what metadata to provide +message Call { + + // The name of the endpoint + string name = 1; + + // The payload of the endpoint + google.protobuf.Any payload = 2; + + // Whether or not to stream the response + bool streamed = 3; + + // The metadata / headers to send with the call + repeated Metadata metadata = 4; +} - // The command payload. - google.protobuf.Any payload = 4; +// This Metadata construct should obey the exact same rules as traditional gRPC Metadata +message Metadata { + // The name of this piece of metadata + string name = 1; - // Whether the command is streamed or not - bool streamed = 5; + // The value of the metadata + string value = 2; } message StreamCancelled { diff --git a/protocols/protocol/cloudstate/function.proto b/protocols/protocol/cloudstate/function.proto index d0e54ead5..827898b73 100644 --- a/protocols/protocol/cloudstate/function.proto +++ b/protocols/protocol/cloudstate/function.proto @@ -28,13 +28,10 @@ option go_package = "cloudstate/protocol"; message FunctionCommand { // The name of the service this function is on. - string service_name = 2; + string service_name = 2; // TODO revisit this ordinal value - // Command name - string name = 3; - - // The command payload. - google.protobuf.Any payload = 4; + // The call to make to that service + Call call = 5; // TODO revisit this ordinal value } message FunctionReply { diff --git a/proxy/core/src/main/proto/cloudstate/proxy/statemanager.proto b/proxy/core/src/main/proto/cloudstate/proxy/statemanager.proto index c75b4092c..d5bf6e0e4 100644 --- a/proxy/core/src/main/proto/cloudstate/proxy/statemanager.proto +++ b/proxy/core/src/main/proto/cloudstate/proxy/statemanager.proto @@ -30,15 +30,12 @@ option (scalapb.options) = { }; message UserFunctionCommand { - string name = 1; - google.protobuf.Any payload = 2; + Call call = 1; } message EntityCommand { string entity_id = 1; - string name = 2; - google.protobuf.Any payload = 3; - bool streamed = 4; + Call call = 2; } message UserFunctionReply {