From 8e01d24e7a744b10f4111a97e01c753b3e9c5114 Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 13 Mar 2025 10:45:25 +0300 Subject: [PATCH 1/6] Include `RemoteServiceConfigurationProvider` in the client proxies documentation --- .../api-development/dynamic-csharp-clients.md | 25 +++++++++++++++++++ .../api-development/static-csharp-clients.md | 23 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index def0b76360..a5cdf94bbe 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/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) diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index 696507bd09..debbfc262d 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/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. From 3bfe0cd0ebbb5560df3c4c3f9defa0cc7ab3adb8 Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 13 Mar 2025 10:48:12 +0300 Subject: [PATCH 2/6] Update Remote Service Configuration Provider doc --- docs/en/framework/api-development/dynamic-csharp-clients.md | 2 +- docs/en/framework/api-development/static-csharp-clients.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index a5cdf94bbe..c3f70d016a 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/docs/en/framework/api-development/dynamic-csharp-clients.md @@ -164,7 +164,7 @@ 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. +You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `RemoteServiceConfigurationProvider` interface. **Example: Get the remote service configuration for the "BookStore" remote service** diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index debbfc262d..8fa14b9b4a 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/docs/en/framework/api-development/static-csharp-clients.md @@ -245,7 +245,7 @@ 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. +You may need to get the remote service configuration for a specific remote service in some cases. For this, you can use the `RemoteServiceConfigurationProvider` interface. **Example: Get the remote service configuration for the "BookStore" remote service** From ab86390cbe07b7f1027bcea1eb0d1255940b3e36 Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 13 Mar 2025 14:16:52 +0300 Subject: [PATCH 3/6] Updated to use `IRemoteServiceConfigurationProvider ` --- docs/en/framework/api-development/dynamic-csharp-clients.md | 6 +++--- docs/en/framework/api-development/static-csharp-clients.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index c3f70d016a..308621897a 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/docs/en/framework/api-development/dynamic-csharp-clients.md @@ -171,16 +171,16 @@ You may need to get the remote service configuration for a specific remote servi ````csharp public class MyService : ITransientDependency { - private readonly RemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; + private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; - public MyService(RemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) { _remoteServiceConfigurationProvider = remoteServiceConfigurationProvider; } public async Task GetRemoteServiceConfiguration() { - var configuration = await _remoteServiceConfigurationProvider.GetConfigurationAsync("BookStore"); + var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore"); Console.WriteLine(configuration.BaseUrl); } } diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index 8fa14b9b4a..61a4f3b169 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/docs/en/framework/api-development/static-csharp-clients.md @@ -252,16 +252,16 @@ You may need to get the remote service configuration for a specific remote servi ````csharp public class MyService : ITransientDependency { - private readonly RemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; + private readonly IRemoteServiceConfigurationProvider _remoteServiceConfigurationProvider; - public MyService(RemoteServiceConfigurationProvider remoteServiceConfigurationProvider) + public MyService(IRemoteServiceConfigurationProvider remoteServiceConfigurationProvider) { _remoteServiceConfigurationProvider = remoteServiceConfigurationProvider; } public async Task GetRemoteServiceConfiguration() { - var configuration = await _remoteServiceConfigurationProvider.GetConfigurationAsync("BookStore"); + var configuration = await _remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("BookStore"); Console.WriteLine(configuration.BaseUrl); } } From b66ec8c4cd0678987bffe26cf0f0769276e57365 Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 13 Mar 2025 14:17:39 +0300 Subject: [PATCH 4/6] Update RemoteServiceConfigurationProvider usage with IRemoteServiceConfigurationProvider --- docs/en/framework/api-development/dynamic-csharp-clients.md | 2 +- docs/en/framework/api-development/static-csharp-clients.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index 308621897a..a97f197fc1 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/docs/en/framework/api-development/dynamic-csharp-clients.md @@ -164,7 +164,7 @@ 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 `RemoteServiceConfigurationProvider` interface. +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** diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index 61a4f3b169..fdf33eea27 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/docs/en/framework/api-development/static-csharp-clients.md @@ -245,7 +245,7 @@ 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 `RemoteServiceConfigurationProvider` interface. +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** From be883dc9af185d49ace2a007361e45864a78beb3 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 13 Mar 2025 19:29:45 +0800 Subject: [PATCH 5/6] Update dynamic-csharp-clients.md --- docs/en/framework/api-development/dynamic-csharp-clients.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/framework/api-development/dynamic-csharp-clients.md b/docs/en/framework/api-development/dynamic-csharp-clients.md index a97f197fc1..a5dc2ec1cf 100644 --- a/docs/en/framework/api-development/dynamic-csharp-clients.md +++ b/docs/en/framework/api-development/dynamic-csharp-clients.md @@ -164,6 +164,7 @@ 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** From 5cd7e99278f5847c197ba4c3918aa3fc6739b792 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 13 Mar 2025 19:29:56 +0800 Subject: [PATCH 6/6] Update static-csharp-clients.md --- docs/en/framework/api-development/static-csharp-clients.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/framework/api-development/static-csharp-clients.md b/docs/en/framework/api-development/static-csharp-clients.md index fdf33eea27..c8eaea4231 100644 --- a/docs/en/framework/api-development/static-csharp-clients.md +++ b/docs/en/framework/api-development/static-csharp-clients.md @@ -245,6 +245,7 @@ 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**