Class RandomLoadBalancer
Returns random service instances.
Inheritance
Implements
Namespace: Steeltoe.Discovery.HttpClients.LoadBalancers
Assembly: Steeltoe.Discovery.HttpClients.dll
Syntax
public sealed class RandomLoadBalancer : object, ILoadBalancer
Constructors
| Edit this page View SourceRandomLoadBalancer(ServiceInstancesResolver, ILogger<RandomLoadBalancer>)
Initializes a new instance of the RandomLoadBalancer class.
Declaration
public RandomLoadBalancer(ServiceInstancesResolver serviceInstancesResolver, ILogger<RandomLoadBalancer> logger)
Parameters
Type | Name | Description |
---|---|---|
ServiceInstancesResolver | serviceInstancesResolver | Used to retrieve the available service instances. |
ILogger<RandomLoadBalancer> | logger | Used for internal logging. Pass |
Methods
| Edit this page View SourceResolveServiceInstanceAsync(Uri, CancellationToken)
Evaluates a URI for a hostname that can be resolved into a service instance.
Declaration
public async Task<Uri> ResolveServiceInstanceAsync(Uri requestUri, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Uri | requestUri | A URI containing a service name that can be resolved into one or more service instances. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<Uri> | The original URI, with the scheme and service name replaced by the scheme, host and port of a service instance. |
UpdateStatisticsAsync(Uri, Uri, Nullable<TimeSpan>, Nullable<Exception>, CancellationToken)
A mechanism for tracking statistics for service instances.
Declaration
public Task UpdateStatisticsAsync(Uri requestUri, Uri serviceInstanceUri, TimeSpan? responseTime, Exception? exception, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Uri | requestUri | The original request URI. |
Uri | serviceInstanceUri | The URI resolved by the load balancer. |
System.Nullable<TimeSpan> | responseTime | The amount of time taken for a remote call to complete. |
System.Nullable<Exception> | exception | Any exception thrown during calls to a resolved service instance. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |