Class ConsulServiceRegistry
An implementation of a Consul service registry
public class ConsulServiceRegistry : IConsulServiceRegistry, IServiceRegistry<IConsulRegistration>, IDisposable
- Inheritance
-
ConsulServiceRegistry
- Implements
- Inherited Members
Constructors
ConsulServiceRegistry(IConsulClient, IOptionsMonitor<ConsulDiscoveryOptions>, IScheduler, ILogger<ConsulServiceRegistry>)
Initializes a new instance of the ConsulServiceRegistry class.
public ConsulServiceRegistry(IConsulClient client, IOptionsMonitor<ConsulDiscoveryOptions> optionsMonitor, IScheduler scheduler = null, ILogger<ConsulServiceRegistry> logger = null)
Parameters
clientIConsulClientthe Consul client to use
optionsMonitorIOptionsMonitor<ConsulDiscoveryOptions>the configuration options
schedulerISchedulera scheduler to use for heart beats
loggerILogger<ConsulServiceRegistry>an optional logger
ConsulServiceRegistry(IConsulClient, ConsulDiscoveryOptions, IScheduler, ILogger<ConsulServiceRegistry>)
Initializes a new instance of the ConsulServiceRegistry class.
public ConsulServiceRegistry(IConsulClient client, ConsulDiscoveryOptions options, IScheduler scheduler = null, ILogger<ConsulServiceRegistry> logger = null)
Parameters
clientIConsulClientthe Consul client to use
optionsConsulDiscoveryOptionsthe configuration options
schedulerISchedulera scheduler to use for heart beats
loggerILogger<ConsulServiceRegistry>an optional logger
Methods
Deregister(IConsulRegistration)
Deregister a service instance in the service registry
public void Deregister(IConsulRegistration registration)
Parameters
registrationIConsulRegistrationthe service instance to register
DeregisterAsync(IConsulRegistration)
Deregister the provided registration in Consul
public Task DeregisterAsync(IConsulRegistration registration)
Parameters
registrationIConsulRegistrationthe registration to register
Returns
- Task
the task
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
~ConsulServiceRegistry()
protected ~ConsulServiceRegistry()
GetStatusAsync(IConsulRegistration)
Get the status of the registration in Consul
public Task<object> GetStatusAsync(IConsulRegistration registration)
Parameters
registrationIConsulRegistrationthe registration to register
Returns
GetStatusAsyncInternal(IConsulRegistration)
public Task<object> GetStatusAsyncInternal(IConsulRegistration registration)
Parameters
registrationIConsulRegistration
Returns
GetStatus<S>(IConsulRegistration)
Return the current status of the service registry registration
public S GetStatus<S>(IConsulRegistration registration) where S : class
Parameters
registrationIConsulRegistrationthe service registration to obtain status for
Returns
- S
the returned status
Type Parameters
Sthe status
Register(IConsulRegistration)
Register a service instance in the service registry
public void Register(IConsulRegistration registration)
Parameters
registrationIConsulRegistrationthe service instance to register
RegisterAsync(IConsulRegistration)
Register the provided registration in Consul
public Task RegisterAsync(IConsulRegistration registration)
Parameters
registrationIConsulRegistrationthe registration to register
Returns
- Task
the task
SetStatus(IConsulRegistration, string)
Update the registration in the service registry with the provided status
public void SetStatus(IConsulRegistration registration, string status)
Parameters
registrationIConsulRegistrationthe registration to update
statusstringthe status
SetStatusAsync(IConsulRegistration, string)
Set the status of the registration in Consul
public Task SetStatusAsync(IConsulRegistration registration, string status)
Parameters
registrationIConsulRegistrationthe registration to register
statusstringthe status value to set
Returns
- Task
the task