Table of Contents

Class ConsulDiscoveryClient

Namespace
Steeltoe.Discovery.Consul.Discovery
Assembly
Steeltoe.Discovery.Consul.dll

A IDiscoveryClient implementation for Consul

public class ConsulDiscoveryClient : IConsulDiscoveryClient, IDiscoveryClient, IServiceInstanceProvider, IDisposable
Inheritance
ConsulDiscoveryClient
Implements
Inherited Members

Constructors

ConsulDiscoveryClient(IConsulClient, IOptionsMonitor<ConsulDiscoveryOptions>, IConsulServiceRegistrar, ILogger<ConsulDiscoveryClient>)

Initializes a new instance of the ConsulDiscoveryClient class.

public ConsulDiscoveryClient(IConsulClient client, IOptionsMonitor<ConsulDiscoveryOptions> optionsMonitor, IConsulServiceRegistrar registrar = null, ILogger<ConsulDiscoveryClient> logger = null)

Parameters

client IConsulClient

a Consule client

optionsMonitor IOptionsMonitor<ConsulDiscoveryOptions>

the configuration options

registrar IConsulServiceRegistrar

a Consul registrar service

logger ILogger<ConsulDiscoveryClient>

optional logger

ConsulDiscoveryClient(IConsulClient, ConsulDiscoveryOptions, IConsulServiceRegistrar, ILogger<ConsulDiscoveryClient>)

Initializes a new instance of the ConsulDiscoveryClient class.

public ConsulDiscoveryClient(IConsulClient client, ConsulDiscoveryOptions options, IConsulServiceRegistrar registrar = null, ILogger<ConsulDiscoveryClient> logger = null)

Parameters

client IConsulClient

a Consul client

options ConsulDiscoveryOptions

the configuration options

registrar IConsulServiceRegistrar

a Consul registrar service

logger ILogger<ConsulDiscoveryClient>

optional logger

Properties

Description

Gets a human readable description of the implementation

public string Description { get; }

Property Value

string

Services

Gets all known service Ids

public IList<string> Services { get; }

Property Value

IList<string>

Methods

Dispose()

Dispose of the client and also the Consul service registrar if provided

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

EnsureAssemblyIsLoaded()

Use this method to prevent Steeltoe.Discovery.Consul from being optimized out of the build

public static void EnsureAssemblyIsLoaded()

~ConsulDiscoveryClient()

protected ~ConsulDiscoveryClient()

GetAllInstances(QueryOptions)

Returns all instances for all services

public IList<IServiceInstance> GetAllInstances(QueryOptions queryOptions = null)

Parameters

queryOptions QueryOptions

any Consul query options to use when doing lookup

Returns

IList<IServiceInstance>

the list of service instances

GetInstances(string)

Get all ServiceInstances associated with a particular serviceId

public IList<IServiceInstance> GetInstances(string serviceId)

Parameters

serviceId string

the serviceId to lookup

Returns

IList<IServiceInstance>

List of service instances

GetInstances(string, QueryOptions)

Returns the instances for the provided service id

public IList<IServiceInstance> GetInstances(string serviceId, QueryOptions queryOptions = null)

Parameters

serviceId string

the service id to get instances for

queryOptions QueryOptions

any Consul query options to use when doing lookup

Returns

IList<IServiceInstance>

the list of service instances

GetLocalServiceInstance()

ServiceInstance with information used to register the local service

public IServiceInstance GetLocalServiceInstance()

Returns

IServiceInstance

The IServiceInstance

GetServices(QueryOptions)

Returns a list of service names in the catalog

public IList<string> GetServices(QueryOptions queryOptions = null)

Parameters

queryOptions QueryOptions

any Consul query options to use when doing lookup

Returns

IList<string>

the list of services

ShutdownAsync()

public Task ShutdownAsync()

Returns

Task