samples/pluggable-components-dotnet...
Pravin Pushkar 5228153f59
Pluggable Secret store template (#164)
* Pluggable Secret store template

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>

* Updating proto and readme

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>

---------

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>
2023-10-11 10:42:45 -07:00
..
Properties Sample/pluggable components (#120) 2022-10-11 22:30:29 -07:00
Protos/dapr/proto/components/v1 Pluggable Secret store template (#164) 2023-10-11 10:42:45 -07:00
Services Pluggable Secret store template (#164) 2023-10-11 10:42:45 -07:00
.gitignore Sample/pluggable components (#120) 2022-10-11 22:30:29 -07:00
Component.csproj Pluggable Secret store template (#164) 2023-10-11 10:42:45 -07:00
Program.cs Pluggable Secret store template (#164) 2023-10-11 10:42:45 -07:00
README.md Pluggable Secret store template (#164) 2023-10-11 10:42:45 -07:00
appsettings.Development.json Sample/pluggable components (#120) 2022-10-11 22:30:29 -07:00
appsettings.json Sample/pluggable components (#120) 2022-10-11 22:30:29 -07:00

README.md

Dapr Pluggable Components Dotnet Template

Sample info

Attribute Details
Dapr runtime version 1.12.0
Language .NET
Environment Local

Overview

This is a template project that enables you to build a pluggable statestore component in .NET.

Run the sample

Prerequisites

Step 1 - Clone the sample repository

  1. Clone the sample repo, then navigate to the pluggable-components-dotnet-template sample:
git clone https://github.com/dapr/samples.git
cd samples/pluggable-components-dotnet-sample
  1. 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:

// 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<StateStoreService> _logger;
    public StateStoreService(ILogger<StateStoreService> logger)
    {
        _logger = logger;
    }
}

Step 2 - Register your unimplemented service

Once you decide which of proto services you are going to implement, go to the ./Program.cs file and examine the lines 46-50. You'll see commented lines, uncomment based on the services that you chose to implement.

For registering StateStoreService:

// Configure the HTTP request pipeline.
app.MapGrpcService<StateStoreService>(); // Uncomment to register the StateStoreService
// app.MapGrpcService<PubSubService>(); // Uncomment to register the PubSubService
// app.MapGrpcService<InputBindingService>(); // Uncomment to register the InputBindingService
// app.MapGrpcService<OutputBindingService>(); // Uncomment to register the OutputBindingService

Step 3 - Making gRPC requests

  1. Run the sample code by running dotnet run

  2. Based on the previous step you can make calls to any of those services using the grpc_cli tool. The example below show how to execute a Set on StateStore services, but you can apply the same for the others following their proto definitions.

grpc_cli call unix:///tmp/dapr-components-sockets/my-component.sock dapr.proto.components.v1.StateStore/Set "key:'my_key', value:'my_value'"

From now on, you should be able to implement the unimplemented methods from your desired service. Refer to the official Microsoft documentation for development using Protocol Buffers for further information.