Browse Source

Include `RemoteServiceConfigurationProvider` in the client proxies documentation

pull/22355/head
enisn 11 months ago
parent
commit
8e01d24e7a
No known key found for this signature in database GPG Key ID: A052619F04155D1C
  1. 25
      docs/en/framework/api-development/dynamic-csharp-clients.md
  2. 23
      docs/en/framework/api-development/static-csharp-clients.md

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

@ -163,6 +163,29 @@ 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
Some times you may need to get the remote service configuration for a specific remote service in specific cases. For this, you can use the `RemoteServiceConfigurationProvider` interface.
**Example: Get the remote service configuration for the "BookStore" remote service**
````csharp
public class MyService : ITransientDependency
{
private readonly RemoteServiceConfigurationProvider _remoteServiceConfigurationProvider;
public MyService(RemoteServiceConfigurationProvider remoteServiceConfigurationProvider)
{
_remoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
}
public async Task GetRemoteServiceConfiguration()
{
var configuration = await _remoteServiceConfigurationProvider.GetConfigurationAsync("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 +227,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)

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

@ -244,6 +244,29 @@ 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
Some times you may need to get the remote service configuration for a specific remote service in specific cases. For this, you can use the `RemoteServiceConfigurationProvider` interface.
**Example: Get the remote service configuration for the "BookStore" remote service**
````csharp
public class MyService : ITransientDependency
{
private readonly RemoteServiceConfigurationProvider _remoteServiceConfigurationProvider;
public MyService(RemoteServiceConfigurationProvider remoteServiceConfigurationProvider)
{
_remoteServiceConfigurationProvider = remoteServiceConfigurationProvider;
}
public async Task GetRemoteServiceConfiguration()
{
var configuration = await _remoteServiceConfigurationProvider.GetConfigurationAsync("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