Table of Contents

Class DiscoveryServiceCollectionExtensions

Namespace
Steeltoe.Discovery.Client
Assembly
Steeltoe.Discovery.ClientBase.dll
public static class DiscoveryServiceCollectionExtensions
Inheritance
DiscoveryServiceCollectionExtensions
Inherited Members

Methods

AddDiscoveryClient(IServiceCollection, IConfiguration)

Adds service discovery to your application. Uses reflection to determine which clients are available and configured. If no clients are available or configured, a Steeltoe.Discovery.Client.SimpleClients.NoOpDiscoveryClient will be configured

public static IServiceCollection AddDiscoveryClient(this IServiceCollection services, IConfiguration config = null)

Parameters

services IServiceCollection

Microsoft.Extensions.DependencyInjection.IServiceCollection to configure

config IConfiguration

Application configuration

Returns

IServiceCollection

AddDiscoveryClient(IServiceCollection, IConfiguration, IDiscoveryLifecycle)

Adds service discovery to your application. Uses reflection to determine which clients are available and configured. If no clients are available or configured, a Steeltoe.Discovery.Client.SimpleClients.NoOpDiscoveryClient will be configured

public static IServiceCollection AddDiscoveryClient(this IServiceCollection services, IConfiguration config, IDiscoveryLifecycle lifecycle = null)

Parameters

services IServiceCollection

Microsoft.Extensions.DependencyInjection.IServiceCollection to configure

config IConfiguration

Application configuration

lifecycle IDiscoveryLifecycle

Add custom code for app shutdown events

Returns

IServiceCollection

AddDiscoveryClient(IServiceCollection, IConfiguration, string, IDiscoveryLifecycle)

Adds service discovery to your application. Uses reflection to determine which clients are available and configured. If no clients are available or configured, a Steeltoe.Discovery.Client.SimpleClients.NoOpDiscoveryClient will be configured

public static IServiceCollection AddDiscoveryClient(this IServiceCollection services, IConfiguration config, string serviceName = null, IDiscoveryLifecycle lifecycle = null)

Parameters

services IServiceCollection

Microsoft.Extensions.DependencyInjection.IServiceCollection to configure

config IConfiguration

Application configuration

serviceName string

Specify the name of a service binding to use

lifecycle IDiscoveryLifecycle

Add custom code for app shutdown events

Returns

IServiceCollection

AddServiceDiscovery(IServiceCollection, Action<DiscoveryClientBuilder>)

Adds service discovery to your application. If builderAction is not provided, a Steeltoe.Discovery.Client.SimpleClients.NoOpDiscoveryClient will be configured

public static IServiceCollection AddServiceDiscovery(this IServiceCollection serviceCollection, Action<DiscoveryClientBuilder> builderAction = null)

Parameters

serviceCollection IServiceCollection

Microsoft.Extensions.DependencyInjection.IServiceCollection to configure

builderAction Action<DiscoveryClientBuilder>

Provided by the desired IDiscoveryClient implementation

Returns

IServiceCollection

Remarks

Also configures named HttpClients "DiscoveryRandom" and "DiscoveryRoundRobin" for automatic injection

Exceptions

AmbiguousMatchException

Thrown if multiple IDiscoveryClient implementations are configured

ConnectorException

Thrown if no service info with expected name or type are found or when multiple service infos are found and a single was expected

GetNamedDiscoveryServiceInfo(IConfiguration, string)

Retrieve a single, named IServiceInfo that is expected to work with Service Discovery

public static IServiceInfo GetNamedDiscoveryServiceInfo(IConfiguration config, string serviceName)

Parameters

config IConfiguration

The IConfiguration to search

serviceName string

Name of service binding to find

Returns

IServiceInfo

Exceptions

ConnectorException

Thrown if no service info with expected name or type are found

GetSingletonDiscoveryServiceInfo(IConfiguration)

Retrieve a single IServiceInfo that is expected to work with Service Discovery

public static IServiceInfo GetSingletonDiscoveryServiceInfo(IConfiguration config)

Parameters

config IConfiguration

The IConfiguration to search

Returns

IServiceInfo

Exceptions

ConnectorException

Thrown if multiple service infos are found