| * 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> | ||
|---|---|---|
| .. | ||
| Properties | ||
| Protos/dapr/proto/components/v1 | ||
| Services | ||
| .gitignore | ||
| Component.csproj | ||
| Program.cs | ||
| README.md | ||
| appsettings.Development.json | ||
| appsettings.json | ||
		
			
				
				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
- .NET Core 6+
- grpc_cli tool for making gRPC calls. There are npm installer and brew formulae available to install.
- Operating system that supports Unix Domain Sockets. UNIX or UNIX-like system (Mac, Linux, or WSL for Windows users)
Step 1 - Clone the sample repository
- 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
- Examine the ./Services/Services.csfile. You'll see four commented classes. They areStateStoreService,PubSubService,InputBindingServiceandOutputBindingService, their protos are defined inside./Protosfolder. 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
- 
Run the sample code by running dotnet run
- 
Based on the previous step you can make calls to any of those services using the grpc_clitool. The example below show how to execute aSetonStateStoreservices, 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.