Skip to content

Commit f987325

Browse files
committed
- change signature of AddRemoteServicesWithNewClient extension method so it cannot return null value
1 parent 47d62cb commit f987325

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ builder.Services.AddRemoteServicesWithNewClient(
366366
{
367367
client.BaseAddress = new Uri(baseAddress);
368368
client.Timeout = TimeSpan.FromSeconds(5);
369-
})?.AddTransientHttpErrorPolicy(
369+
}).AddTransientHttpErrorPolicy(
370370
policyBuilder => policyBuilder.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30)));
371371
```
372372

samples/Client/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{
3131
client.BaseAddress = new Uri(baseAddress);
3232
client.Timeout = TimeSpan.FromSeconds(5);
33-
})?.AddTransientHttpErrorPolicy(
33+
}).AddTransientHttpErrorPolicy(
3434
policyBuilder => policyBuilder.CircuitBreakerAsync(5, TimeSpan.FromSeconds(30)));
3535

3636
using IHost host = builder.Build();

src/ModEndpoints.RemoteServices/DependencyInjectionExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static IServiceCollection AddRemoteServiceToExistingClient<TRequest>(
8989
return services;
9090
}
9191

92-
public static IHttpClientBuilder? AddRemoteServicesWithNewClient(
92+
public static IHttpClientBuilder AddRemoteServicesWithNewClient(
9393
this IServiceCollection services,
9494
Assembly fromAssembly,
9595
string clientName,
@@ -130,6 +130,10 @@ public static IServiceCollection AddRemoteServiceToExistingClient<TRequest>(
130130
clientName);
131131
}
132132
}
133+
if (clientBuilder is null)
134+
{
135+
throw new InvalidOperationException($"Cannot create HttpClient with client name {clientName}.");
136+
}
133137
return clientBuilder;
134138
}
135139

0 commit comments

Comments
 (0)