Skip to content

Commit

Permalink
fix: multiple grpc client with same name registration
Browse files Browse the repository at this point in the history
  • Loading branch information
ronimizy committed Jan 19, 2025
1 parent 4661873 commit 9367f0d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Itmo.Dev.Platform.Grpc/Clients/Builders/ClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ public ClientBuilder(IServiceCollection collection, string serviceName)
{
_collection = collection;

_clientBuilder = collection.AddGrpcClient<TClient>((sp, o) =>
{
var monitor = sp.GetRequiredService<IOptionsMonitor<PlatformGrpcClientOptions>>();
var options = monitor.Get(serviceName);
_clientBuilder = collection.AddGrpcClient<TClient>(
$"{serviceName}:{typeof(TClient).Name}",
(sp, o) =>
{
var monitor = sp.GetRequiredService<IOptionsMonitor<PlatformGrpcClientOptions>>();
var options = monitor.Get(serviceName);

o.Address = options.Address;
});
o.Address = options.Address;
});

_clientBuilder.AddInterceptor<PlatformHeaderClientInterceptor>(InterceptorScope.Client);
_clientBuilder.AddInterceptor<ClientTracingInterceptor>(InterceptorScope.Client);
Expand All @@ -39,4 +41,4 @@ public IPlatformGrpcClientBuilder WithInterceptor<TInterceptor>()

return this;
}
}
}

0 comments on commit 9367f0d

Please sign in to comment.