Browse Source

Merge pull request #22360 from abpframework/auto-merge/rel-9-0/3533

Merge branch rel-9.1 with rel-9.0
pull/22361/head
maliming 2 years ago
committed by GitHub
parent
commit
1797d0a384
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 26
      docs/en/framework/api-development/dynamic-csharp-clients.md
  2. 24
      docs/en/framework/api-development/static-csharp-clients.md

26
docs/en/framework/api-development/dynamic-csharp-clients.md

@ -163,6 +163,30 @@ context.Services.AddHttpClientProxies(
`remoteServiceConfigurationName` parameter matches the service endpoint configured via `AbpRemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint.
#### Remote Service Configuration Provider
You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `IRemoteServiceConfigurationProvider` interface.
**Example: Get the remote service configuration for the "BookStore" remote service**
````csharp
public class MyService : ITransientDependency
{
private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider;
public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider)
{
_remoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
}
public async Task GetRemoteServiceConfiguration()
{
var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore");
Console.WriteLine(configuration.BaseUrl);
}
}
````
### As Default Services
When you create a service proxy for `IBookAppService`, you can directly inject the `IBookAppService` to use the proxy client (as shown in the usage section). You can pass `asDefaultServices: false` to the `AddHttpClientProxies` method to disable this feature.
@ -204,6 +228,8 @@ public override void PreConfigureServices(ServiceConfigurationContext context)
This example uses the [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly) package. You also need to import the `Polly` namespace (`using Polly;`) to be able to use the `WaitAndRetryAsync` method.
## See Also
* [Static C# Client Proxies](./static-csharp-clients.md)

24
docs/en/framework/api-development/static-csharp-clients.md

@ -244,6 +244,30 @@ context.Services.AddStaticHttpClientProxies(
`remoteServiceConfigurationName` parameter matches the service endpoint configured via `AbpRemoteServiceOptions`. If the `BookStore` endpoint is not defined then it fallbacks to the `Default` endpoint.
#### Remote Service Configuration Provider
You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `IRemoteServiceConfigurationProvider` interface.
**Example: Get the remote service configuration for the "BookStore" remote service**
````csharp
public class MyService : ITransientDependency
{
private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider;
public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider)
{
_remoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
}
public async Task GetRemoteServiceConfiguration()
{
var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore");
Console.WriteLine(configuration.BaseUrl);
}
}
````
### Retry/Failure Logic & Polly Integration
If you want to add retry logic for the failing remote HTTP calls for the client proxies, you can configure the `AbpHttpClientBuilderOptions` in the `PreConfigureServices` method of your module class.

Loading…
Cancel
Save