diff --git a/pluggable-components-dotnet-template/Component.csproj b/pluggable-components-dotnet-template/Component.csproj index 0ded16b..a809360 100644 --- a/pluggable-components-dotnet-template/Component.csproj +++ b/pluggable-components-dotnet-template/Component.csproj @@ -10,6 +10,7 @@ + diff --git a/pluggable-components-dotnet-template/Program.cs b/pluggable-components-dotnet-template/Program.cs index cc41802..0beec87 100644 --- a/pluggable-components-dotnet-template/Program.cs +++ b/pluggable-components-dotnet-template/Program.cs @@ -11,6 +11,9 @@ // limitations under the License. // ------------------------------------------------------------------------ +//Uncomment it import Services. +//using DaprComponents.Services; + var componentName = "my-component"; // replace by your component name // default directory for components var socketDir = "/tmp/dapr-components-sockets"; @@ -48,6 +51,7 @@ var app = builder.Build(); // app.MapGrpcService(); // Uncomment to register the PubSubService // app.MapGrpcService(); // Uncomment to register the InputBindingService // app.MapGrpcService(); // Uncomment to register the OutputBindingService +// app.MapGrpcService(); // Uncomment to register the SecretStoreService // gRPC refletion is required for service discovery, do not remove it. app.MapGrpcReflectionService(); diff --git a/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/pubsub.proto b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/pubsub.proto index 26142c0..2754ed6 100644 --- a/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/pubsub.proto +++ b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/pubsub.proto @@ -30,6 +30,8 @@ service PubSub { // Publish publishes a new message for the given topic. rpc Publish(PublishRequest) returns (PublishResponse) {} + rpc BulkPublish(BulkPublishRequest) returns (BulkPublishResponse) {} + // Establishes a stream with the server (PubSub component), which sends // messages down to the client (daprd). The client streams acknowledgements // back to the server. The server will close the stream and return the status @@ -82,6 +84,29 @@ message PublishRequest { string content_type = 5; } +message BulkPublishRequest { + repeated BulkMessageEntry entries = 1; + string pubsub_name = 2; + string topic = 3; + map metadata = 4; +} + +message BulkMessageEntry { + string entry_id = 1; + bytes event = 2; + string content_type = 3; + map metadata = 4; +} + +message BulkPublishResponse { + repeated BulkPublishResponseFailedEntry failed_entries = 1; +} + +message BulkPublishResponseFailedEntry { + string entry_id = 1; + string error = 2; +} + // reserved for future-proof extensibility message PublishResponse {} diff --git a/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/secretstore.proto b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/secretstore.proto new file mode 100644 index 0000000..6a0442d --- /dev/null +++ b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/secretstore.proto @@ -0,0 +1,80 @@ +/* +Copyright 2023 The Dapr Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +syntax = "proto3"; + +package dapr.proto.components.v1; + +import "dapr/proto/components/v1/common.proto"; + +option go_package = "github.com/dapr/dapr/pkg/proto/components/v1;components"; + +// Interface for secret store. +service SecretStore { + // Initializes the secret store with the given metadata. + rpc Init(SecretStoreInitRequest) returns (SecretStoreInitResponse) {} + + // Returns a list of implemented secret store features. + rpc Features(FeaturesRequest) returns (FeaturesResponse) {} + + // Get an individual secret from the store. + rpc Get(GetSecretRequest) returns (GetSecretResponse) {} + + // Get all secrets from the store. + rpc BulkGet(BulkGetSecretRequest) returns (BulkGetSecretResponse) {} + + // Ping the pubsub. Used for liveness porpuses. + rpc Ping(PingRequest) returns (PingResponse) {} + } + +// Request to initialize the secret store. +message SecretStoreInitRequest { + MetadataRequest metadata = 1; +} + +// Response from initialization. +message SecretStoreInitResponse {} + +// GetSecretRequest is the message to get secret from secret store. +message GetSecretRequest { + // The name of secret key. + string key = 1; + + // The metadata which will be sent to secret store components. + map metadata = 2; +} + +// GetSecretResponse is the response message to convey the requested secret. +message GetSecretResponse { + // data is the secret value. Some secret store, such as kubernetes secret + // store, can save multiple secrets for single secret key. + map data = 1; +} + +// BulkGetSecretRequest is the message to get the secrets from secret store. +message BulkGetSecretRequest { + // The metadata which will be sent to secret store components. + map metadata = 1; +} + +// SecretResponse is a map of decrypted string/string values +message SecretResponse { + map secrets = 1; +} + +// BulkGetSecretResponse is the response message to convey the requested secrets. +message BulkGetSecretResponse { + // data hold the secret values. Some secret store, such as kubernetes secret + // store, can save multiple secrets for single secret key. + map data = 1; +} \ No newline at end of file diff --git a/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/state.proto b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/state.proto index dcb049a..ffedd99 100644 --- a/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/state.proto +++ b/pluggable-components-dotnet-template/Protos/dapr/proto/components/v1/state.proto @@ -236,15 +236,25 @@ message SetRequest { // reserved for future-proof extensibility message SetResponse {} +message BulkDeleteRequestOptions { + int64 parallelism = 1; +} + message BulkDeleteRequest { repeated DeleteRequest items = 1; + BulkDeleteRequestOptions options = 2; } // reserved for future-proof extensibility message BulkDeleteResponse {} +message BulkGetRequestOptions { + int64 parallelism = 1; +} + message BulkGetRequest { repeated GetRequest items = 1; + BulkGetRequestOptions options = 2; } message BulkStateItem { @@ -264,11 +274,15 @@ message BulkStateItem { message BulkGetResponse { repeated BulkStateItem items = 1; - bool got = 2; +} + +message BulkSetRequestOptions { + int64 parallelism = 1; } message BulkSetRequest { repeated SetRequest items = 1; + BulkSetRequestOptions options = 2; } // reserved for future-proof extensibility diff --git a/pluggable-components-dotnet-template/README.md b/pluggable-components-dotnet-template/README.md index 94d4711..c49f91d 100644 --- a/pluggable-components-dotnet-template/README.md +++ b/pluggable-components-dotnet-template/README.md @@ -4,7 +4,7 @@ | Attribute | Details | | -------------------- | ------- | -| Dapr runtime version | 1.9.0 | +| Dapr runtime version | 1.12.0 | | Language | .NET | | Environment | Local | @@ -29,7 +29,7 @@ git clone https://github.com/dapr/samples.git cd samples/pluggable-components-dotnet-sample ``` -2. Examine the `./Services/Services.cs` file. You'll see four commented classes. They are `StateStoreService`, `PubSubService`, `InputBindingService` and `OutputBindingService`, their protos are defined inside `./Protos` folder. Uncomment any number of them as these serve as a unimplemented proto service that you start from. +2. Examine the `./Services/Services.cs` file. You'll see four commented classes. They are `StateStoreService`, `PubSubService`, `InputBindingService` and `OutputBindingService`, their protos are defined inside `./Protos` folder. Uncomment any number of them as these serve as an unimplemented proto service that you start from. Uncommenting StateStoreService as an example: diff --git a/pluggable-components-dotnet-template/Services/Services.cs b/pluggable-components-dotnet-template/Services/Services.cs index 5f39e27..34667ad 100644 --- a/pluggable-components-dotnet-template/Services/Services.cs +++ b/pluggable-components-dotnet-template/Services/Services.cs @@ -1,62 +1,73 @@ -// ------------------------------------------------------------------------ -// Copyright 2022 The Dapr Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------ - -// Uncomment to import Dapr proto components namespace. -// using Dapr.Proto.Components.V1; - -namespace DaprComponents.Services; - - -// Uncomment the lines below to implement the StateStore methods defined in the following protofiles -// ./Protos/dapr/proto/components/v1/state.proto#L123 -// public class StateStoreService : StateStore.StateStoreBase -// { -// private readonly ILogger _logger; -// public StateStoreService(ILogger logger) -// { -// _logger = logger; -// } -// } - -// Uncomment the lines below to implement the PubSub methods defined in the following protofiles -// ./Protos/dapr/proto/components/v1/pubsub.proto#L23 -// public class PubSubService : PubSub.PubSubBase -// { -// private readonly ILogger _logger; -// public PubSubService(ILogger logger) -// { -// _logger = logger; -// } -// } - -// Uncomment the lines below to implement the InputBindings methods defined in the following protofiles -// ./Protos/dapr/proto/components/v1/bindings.proto#L23 -// public class InputBindingService : InputBinding.InputBindingBase -// { -// private readonly ILogger _logger; -// public InputBindingService(ILogger logger) -// { -// _logger = logger; -// } -// } - -// Uncomment the lines below to implement the OutputBindings methods defined in the following protofiles -// ./Protos/dapr/proto/components/v1/bindings.proto#L37 -// public class OutputBindingService : OutputBinding.OutputBindingBase -// { -// private readonly ILogger _logger; -// public OutputBindingService(ILogger logger) -// { -// _logger = logger; -// } -// } +// ------------------------------------------------------------------------ +// Copyright 2022 The Dapr Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ------------------------------------------------------------------------ + +// Uncomment to import Dapr proto components namespace. +//using Dapr.Proto.Components.V1; + +namespace DaprComponents.Services; + + +// Uncomment the lines below to implement the StateStore methods defined in the following protofiles +// ./Protos/dapr/proto/components/v1/state.proto#L123 +// public class StateStoreService : StateStore.StateStoreBase +// { +// private readonly ILogger _logger; +// public StateStoreService(ILogger logger) +// { +// _logger = logger; +// } +// } + +// Uncomment the lines below to implement the PubSub methods defined in the following protofiles +// ./Protos/dapr/proto/components/v1/pubsub.proto#L23 +// public class PubSubService : PubSub.PubSubBase +// { +// private readonly ILogger _logger; +// public PubSubService(ILogger logger) +// { +// _logger = logger; +// } +// } + +// Uncomment the lines below to implement the InputBindings methods defined in the following protofiles +// ./Protos/dapr/proto/components/v1/bindings.proto#L23 +// public class InputBindingService : InputBinding.InputBindingBase +// { +// private readonly ILogger _logger; +// public InputBindingService(ILogger logger) +// { +// _logger = logger; +// } +// } + +// Uncomment the lines below to implement the OutputBindings methods defined in the following protofiles +// ./Protos/dapr/proto/components/v1/bindings.proto#L37 +//public class OutputBindingService : OutputBinding.OutputBindingBase +//{ +// private readonly ILogger _logger; +// public OutputBindingService(ILogger logger) +// { +// _logger = logger; +// } +//} + +// Uncomment the lines below to implement the Secret Store methods defined in the following protofiles +// ./Protos/dapr/proto/components/v1/secretstore.proto#23 +// public class SecretStoreService : SecretStore.SecretStoreBase +// { +// private readonly ILogger _logger; +// public SecretStoreService(ILogger logger) +// { +// _logger = logger; +// } +// }