Table of Contents

Class RandomLoadBalancer

Namespace
Steeltoe.Common.LoadBalancer
Assembly
Steeltoe.Common.dll
public class RandomLoadBalancer : ILoadBalancer
Inheritance
RandomLoadBalancer
Implements
Inherited Members

Constructors

RandomLoadBalancer(IServiceInstanceProvider, IDistributedCache, DistributedCacheEntryOptions, ILogger)

Initializes a new instance of the RandomLoadBalancer class. Returns random service instances, with option caching of service lookups

public RandomLoadBalancer(IServiceInstanceProvider serviceInstanceProvider, IDistributedCache distributedCache = null, DistributedCacheEntryOptions cacheEntryOptions = null, ILogger logger = null)

Parameters

serviceInstanceProvider IServiceInstanceProvider

Provider of service instance information

distributedCache IDistributedCache

For caching service instance data

cacheEntryOptions DistributedCacheEntryOptions

Configuration for cache entries of service instance data

logger ILogger

For logging

Methods

ResolveServiceInstanceAsync(Uri)

Evaluates a URI for a host name that can be resolved into a service instance

public virtual Task<Uri> ResolveServiceInstanceAsync(Uri request)

Parameters

request Uri

A URI containing a service name that can be resolved into one or more service instances

Returns

Task<Uri>

The original URI, with serviceName replaced by the host:port of a service instance

UpdateStatsAsync(Uri, Uri, TimeSpan, Exception)

A mechanism for tracking statistics for service instances

public virtual Task UpdateStatsAsync(Uri originalUri, Uri resolvedUri, TimeSpan responseTime, Exception exception)

Parameters

originalUri Uri

The original request URI

resolvedUri Uri

The URI resolved by the load balancer

responseTime TimeSpan

The amount of time taken for a remote call to complete

exception Exception

Any exception called during calls to a resolved service instance

Returns

Task

A task