From 3cab20a1b6b167927fe028c835f98f5f8267d043 Mon Sep 17 00:00:00 2001 From: Phillip Hoff Date: Fri, 16 Feb 2024 13:55:40 -0800 Subject: [PATCH] Update protos and related use for Dapr 1.13. (#1236) * Update protos and related use. Signed-off-by: Phillip Hoff * Update Dapr runtime version. Signed-off-by: Phillip Hoff * Init properties. Signed-off-by: Phillip Hoff --------- Signed-off-by: Phillip Hoff --- .github/workflows/itests.yml | 2 +- src/Dapr.Client/DaprClientGrpc.cs | 6 +-- src/Dapr.Client/DaprMetadata.cs | 1 + .../Protos/dapr/proto/dapr/v1/dapr.proto | 54 +++++++++++++------ .../DaprClientTest.InvokeMethodGrpcAsync.cs | 5 +- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/.github/workflows/itests.yml b/.github/workflows/itests.yml index 3267783c0..73d038400 100644 --- a/.github/workflows/itests.yml +++ b/.github/workflows/itests.yml @@ -43,7 +43,7 @@ jobs: GOARCH: amd64 GOPROXY: https://proxy.golang.org DAPR_CLI_VER: 1.12.0 - DAPR_RUNTIME_VER: 1.12.0 + DAPR_RUNTIME_VER: 1.13.0-rc.2 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/release-1.12/install/install.sh DAPR_CLI_REF: '' steps: diff --git a/src/Dapr.Client/DaprClientGrpc.cs b/src/Dapr.Client/DaprClientGrpc.cs index f856b87e6..3cd7de526 100644 --- a/src/Dapr.Client/DaprClientGrpc.cs +++ b/src/Dapr.Client/DaprClientGrpc.cs @@ -2340,7 +2340,7 @@ public override async Task WaitForSidecarAsync(CancellationToken cancellationTok /// public async override Task ShutdownSidecarAsync(CancellationToken cancellationToken = default) { - await client.ShutdownAsync(new Empty(), CreateCallOptions(null, cancellationToken)); + await client.ShutdownAsync(new Autogenerated.ShutdownRequest(), CreateCallOptions(null, cancellationToken)); } /// @@ -2349,9 +2349,9 @@ public override async Task GetMetadataAsync(CancellationToken canc var options = CreateCallOptions(headers: null, cancellationToken); try { - var response = await client.GetMetadataAsync(new Empty(), options); + var response = await client.GetMetadataAsync(new Autogenerated.GetMetadataRequest(), options); return new DaprMetadata(response.Id, - response.ActiveActorsCount.Select(c => new DaprActorMetadata(c.Type, c.Count)).ToList(), + response.ActorRuntime.ActiveActors.Select(c => new DaprActorMetadata(c.Type, c.Count)).ToList(), response.ExtendedMetadata.ToDictionary(c => c.Key, c => c.Value), response.RegisteredComponents.Select(c => new DaprComponentsMetadata(c.Name, c.Type, c.Version, c.Capabilities.ToArray())).ToList()); } diff --git a/src/Dapr.Client/DaprMetadata.cs b/src/Dapr.Client/DaprMetadata.cs index 4cd812e04..a58707c99 100644 --- a/src/Dapr.Client/DaprMetadata.cs +++ b/src/Dapr.Client/DaprMetadata.cs @@ -11,6 +11,7 @@ // limitations under the License. // ------------------------------------------------------------------------ +using System; using System.Collections.Generic; namespace Dapr.Client diff --git a/src/Dapr.Client/Protos/dapr/proto/dapr/v1/dapr.proto b/src/Dapr.Client/Protos/dapr/proto/dapr/v1/dapr.proto index eafb5452e..5ec1cc9d8 100644 --- a/src/Dapr.Client/Protos/dapr/proto/dapr/v1/dapr.proto +++ b/src/Dapr.Client/Protos/dapr/proto/dapr/v1/dapr.proto @@ -79,9 +79,6 @@ service Dapr { // Unregister an actor reminder. rpc UnregisterActorReminder(UnregisterActorReminderRequest) returns (google.protobuf.Empty) {} - // Rename an actor reminder. - rpc RenameActorReminder(RenameActorReminderRequest) returns (google.protobuf.Empty) {} - // Gets the state for a specific actor. rpc GetActorState(GetActorStateRequest) returns (GetActorStateResponse) {} @@ -122,7 +119,7 @@ service Dapr { rpc DecryptAlpha1(stream DecryptRequest) returns (stream DecryptResponse); // Gets metadata of the sidecar - rpc GetMetadata (google.protobuf.Empty) returns (GetMetadataResponse) {} + rpc GetMetadata (GetMetadataRequest) returns (GetMetadataResponse) {} // Sets value in extended metadata of the sidecar rpc SetMetadata (SetMetadataRequest) returns (google.protobuf.Empty) {} @@ -190,7 +187,7 @@ service Dapr { // Raise an event to a running workflow instance rpc RaiseEventWorkflowBeta1 (RaiseEventWorkflowRequest) returns (google.protobuf.Empty) {} // Shutdown the sidecar - rpc Shutdown (google.protobuf.Empty) returns (google.protobuf.Empty) {} + rpc Shutdown (ShutdownRequest) returns (google.protobuf.Empty) {} } // InvokeServiceRequest represents the request message for Service invocation. @@ -407,7 +404,6 @@ message BulkPublishResponse { // BulkPublishResponseFailedEntry is the message containing the entryID and error of a failed event in BulkPublishEvent call message BulkPublishResponseFailedEntry { - // The response scoped unique ID referring to this message string entry_id = 1; @@ -415,7 +411,6 @@ message BulkPublishResponseFailedEntry { string error = 2; } - // InvokeBindingRequest is the message to send data to output bindings message InvokeBindingRequest { // The name of the output binding to invoke. @@ -544,14 +539,6 @@ message UnregisterActorReminderRequest { string name = 3; } -// RenameActorReminderRequest is the message to rename an actor reminder. -message RenameActorReminderRequest { - string actor_type = 1; - string actor_id = 2; - string old_name = 3; - string new_name = 4; -} - // GetActorStateRequest is the message to get key-value states from specific actor. message GetActorStateRequest { string actor_type = 1; @@ -600,10 +587,16 @@ message InvokeActorResponse { bytes data = 1; } -// GetMetadataResponse is a message that is returned on GetMetadata rpc call +// GetMetadataRequest is the message for the GetMetadata request. +message GetMetadataRequest { + // Empty +} + +// GetMetadataResponse is a message that is returned on GetMetadata rpc call. message GetMetadataResponse { string id = 1; - repeated ActiveActorsCount active_actors_count = 2 [json_name = "actors"]; + // Deprecated alias for actor_runtime.active_actors. + repeated ActiveActorsCount active_actors_count = 2 [json_name = "actors", deprecated = true]; repeated RegisteredComponents registered_components = 3 [json_name = "components"]; map extended_metadata = 4 [json_name = "extended"]; repeated PubsubSubscription subscriptions = 5 [json_name = "subscriptions"]; @@ -611,6 +604,28 @@ message GetMetadataResponse { AppConnectionProperties app_connection_properties = 7 [json_name = "appConnectionProperties"]; string runtime_version = 8 [json_name = "runtimeVersion"]; repeated string enabled_features = 9 [json_name = "enabledFeatures"]; + ActorRuntime actor_runtime = 10 [json_name = "actorRuntime"]; +} + +message ActorRuntime { + enum ActorRuntimeStatus { + // Indicates that the actor runtime is still being initialized. + INITIALIZING = 0; + // Indicates that the actor runtime is disabled. + // This normally happens when Dapr is started without "placement-host-address" + DISABLED = 1; + // Indicates the actor runtime is running, either as an actor host or client. + RUNNING = 2; + } + + // Contains an enum indicating whether the actor runtime has been initialized. + ActorRuntimeStatus runtime_status = 1 [json_name = "runtimeStatus"]; + // Count of active actors per type. + repeated ActiveActorsCount active_actors = 2 [json_name = "activeActors"]; + // Indicates whether the actor runtime is ready to host actors. + bool host_ready = 3 [json_name = "hostReady"]; + // Custom message from the placement provider. + string placement = 4 [json_name = "placement"]; } message ActiveActorsCount { @@ -1088,3 +1103,8 @@ message PurgeWorkflowRequest { // Name of the workflow component. string workflow_component = 2 [json_name = "workflowComponent"]; } + +// ShutdownRequest is the request for Shutdown. +message ShutdownRequest { + // Empty +} diff --git a/test/Dapr.Client.Test/DaprClientTest.InvokeMethodGrpcAsync.cs b/test/Dapr.Client.Test/DaprClientTest.InvokeMethodGrpcAsync.cs index 5412c4063..4001e4b06 100644 --- a/test/Dapr.Client.Test/DaprClientTest.InvokeMethodGrpcAsync.cs +++ b/test/Dapr.Client.Test/DaprClientTest.InvokeMethodGrpcAsync.cs @@ -368,7 +368,7 @@ public async Task GetMetadataAsync_WrapsRpcException() var rpcException = new RpcException(rpcStatus, new Metadata(), rpcExceptionMessage); client.Mock - .Setup(m => m.GetMetadataAsync(It.IsAny(), It.IsAny())) + .Setup(m => m.GetMetadataAsync(It.IsAny(), It.IsAny())) .Throws(rpcException); var ex = await Assert.ThrowsAsync(async () => @@ -395,9 +395,10 @@ public async Task GetMetadataAsync_WithReturnTypeAndData() // Create Response & Respond var response = new Autogen.Grpc.v1.GetMetadataResponse() { + ActorRuntime = new(), Id = "testId", }; - response.ActiveActorsCount.Add(new ActiveActorsCount { Type = "testType", Count = 1 }); + response.ActorRuntime.ActiveActors.Add(new ActiveActorsCount { Type = "testType", Count = 1 }); response.RegisteredComponents.Add(new RegisteredComponents { Name = "testName", Type = "testType", Version = "V1" }); response.ExtendedMetadata.Add("e1", "v1");