Class ConsulDiscoveryClient
A IDiscoveryClient implementation for Consul
public class ConsulDiscoveryClient : IConsulDiscoveryClient, IDiscoveryClient, IServiceInstanceProvider, IDisposable
- Inheritance
-
ConsulDiscoveryClient
- Implements
- Inherited Members
- Extension Methods
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
clientIConsulClienta Consule client
optionsMonitorIOptionsMonitor<ConsulDiscoveryOptions>the configuration options
registrarIConsulServiceRegistrara Consul registrar service
loggerILogger<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
clientIConsulClienta Consul client
optionsConsulDiscoveryOptionsthe configuration options
registrarIConsulServiceRegistrara Consul registrar service
loggerILogger<ConsulDiscoveryClient>optional logger
Properties
Description
Gets a human readable description of the implementation
public string Description { get; }
Property Value
Services
Gets all known service Ids
public IList<string> Services { get; }
Property Value
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
disposingbool
~ConsulDiscoveryClient()
protected ~ConsulDiscoveryClient()
GetAllInstances(QueryOptions)
Returns all instances for all services
public IList<IServiceInstance> GetAllInstances(QueryOptions queryOptions = null)
Parameters
queryOptionsQueryOptionsany 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
serviceIdstringthe 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
serviceIdstringthe service id to get instances for
queryOptionsQueryOptionsany 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
queryOptionsQueryOptionsany Consul query options to use when doing lookup
Returns
ShutdownAsync()
public Task ShutdownAsync()