Configuring the GrpcChannelOptions when using CreateInvocationInvoker
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 378
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
Hey,
we use [protobuf.net-Grpc](https://github.com/protobuf-net/protobuf-net.Grpc) for [code-first gRPC services](https://learn.microsoft.com/en-us/aspnet/core/grpc/code-first?view=aspnetcore-9.0). In its current form, this relies on `DaprClient.CreateInvocationInvoker` to create a `CallInvoker` which is then used to create the gRPC service client.
That looks for example like this and works fine:
```csharp
var client = DaprClient
.CreateInvocationInvoker("demo-server")
.CreateGrpcService();
```
The problem now comes when wanting to use `GrpcChannelOptions`, e.g. to change the maximum request/response sizes. The usual way in Dapr is to configure the channel options with the DaprClientBuilder:
```csharp
// manual client creation
var daprClient = new DaprClientBuilder()
.UseGrpcChannelOptions(new GrpcChannelOptions { MaxReceiveMessageSize = 16 * 1024 * 1024 })
.Build();
// or when using Dapr.AspNetCore
builder.Services.AddDaprClient(builder =>
{
builder.UseGrpcChannelOptions(new GrpcChannelOptions { MaxReceiveMessageSize = 16 * 1024 * 1024 })
});
```
However, this configuration is only used when using the DaprClientBuilder to create a DaprClient. This however is not useful when using other means of creating a client, e.g. code-first servies with protobuf.net-Grpc.
So right now, there is no way to pass in GrpcChannelOptions when using `CreateInvocationInvoker`. The method creates the channel using `GrpcChannel.ForAddress` without passing any channel options which means the default channel options will always be used.
### Suggestion
I would propose to add an overload to `CreateInvocationInvoker` which takes a `GrpcChannelOptions` object that is then used when creating the channel.
### Additional details
My current (working) workaround copies the `CreateInvocationInvoker` method and the internal methods from `DaprDefaults`. So this is already working in our setup.
I also have this change [ready in my fork](https://github.com/poke/dapr-dotnet-sdk/commit/60053e307744d03a4bd5a2f235b247d53ab158e8), if you accept this feature request.
## Release Note
**ADD** Ability to configure the gRPC channel options when using CreateInvocationInvoker
Contributor guide
Assessment
This issue has not been assessed yet.