Skip to content

Support AddAsKeyed on AddGrpcClient #2598

Open
@jakoss

Description

@jakoss

Is your feature request related to a problem? Please describe.

I want to used Keyed Services feature with named grpc clients. Right now i have something like this:

serviceCollection.AddGrpcClient<MyGrpcServiceClient>("custom_name", o =>
{
    o.Address = new Uri(someUrl);
});

But to access this named client i have to inject GrpcClientFactory and all Create on it. In .NET 9 IHttpClientBuilder introduced AddAsKeyed that does exactly that for http clients, but it seems to be ignored for grpc clients.

Describe the solution you'd like

What i would love to have is that i can inject my named client directly like that:

app.MapGet("/", ([FromKeyedServices("custom_name")] MyGrpcServiceClient client) => ... );

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions