Class ClientFactoryService
- Namespace
- FoundationaLLM.Common.Services.API
- Assembly
- FoundationaLLM.Common.dll
Provides methods for creating client pipelines for communication with API endpoints.
public class ClientFactoryService : IClientFactoryService
- Inheritance
-
ClientFactoryService
- Implements
- Inherited Members
- Extension Methods
Remarks
This service abstracts the creation of client pipelines, allowing clients to establish connections using either an instance identifier and client name or a specific API endpoint configuration. Implementations may enforce authentication or configuration requirements depending on the provided parameters.
Constructors
ClientFactoryService(IServiceProvider, IConfiguration)
Provides methods for creating client pipelines for communication with API endpoints.
public ClientFactoryService(IServiceProvider serviceProvider, IConfiguration configuration)
Parameters
serviceProviderIServiceProviderThe IServiceProvider for the main DI container.
configurationIConfigurationThe IConfiguration used to retrieve app settings from configuration.
Remarks
This service abstracts the creation of client pipelines, allowing clients to establish connections using either an instance identifier and client name or a specific API endpoint configuration. Implementations may enforce authentication or configuration requirements depending on the provided parameters.
Methods
CreateClient<T>(string, string, UnifiedUserIdentity, Func<Dictionary<string, object>, T>, Dictionary<string, object>?)
Creates a T client instance based on the client name and a client builder delegate.
public Task<T> CreateClient<T>(string instanceId, string clientName, UnifiedUserIdentity userIdentity, Func<Dictionary<string, object>, T> clientBuilder, Dictionary<string, object>? clientBuilderParameters = null)
Parameters
instanceIdstringThe FoundationaLLM instance identifier.
clientNamestringThe name of the HTTP client to create. This name must be registered as an APIEndpointConfiguration resource in the FoundationaLLM.Configuration resource provider.
userIdentityUnifiedUserIdentityThe UnifiedUserIdentity of the caller requesting the client.
clientBuilderFunc<Dictionary<string, object>, T>A delegate that creates the
Tclient instance based on a dictionary of values. The keys available in the dictionary are defined in HttpClientFactoryServiceKeyNames.clientBuilderParametersDictionary<string, object>A dictionary of parameters to pass to the client builder delegate.
Returns
- Task<T>
A
Tclient instance.
Type Parameters
TThe type of the client to create.