Table of Contents

Class ConsulServiceRegistry

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

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

client IConsulClient

the Consul client to use

optionsMonitor IOptionsMonitor<ConsulDiscoveryOptions>

the configuration options

scheduler IScheduler

a scheduler to use for heart beats

logger ILogger<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

client IConsulClient

the Consul client to use

options ConsulDiscoveryOptions

the configuration options

scheduler IScheduler

a scheduler to use for heart beats

logger ILogger<ConsulServiceRegistry>

an optional logger

Methods

Deregister(IConsulRegistration)

Deregister a service instance in the service registry

public void Deregister(IConsulRegistration registration)

Parameters

registration IConsulRegistration

the service instance to register

DeregisterAsync(IConsulRegistration)

Deregister the provided registration in Consul

public Task DeregisterAsync(IConsulRegistration registration)

Parameters

registration IConsulRegistration

the registration to register

Returns

Task

the task

Dispose()

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

~ConsulServiceRegistry()

protected ~ConsulServiceRegistry()

GetStatusAsync(IConsulRegistration)

Get the status of the registration in Consul

public Task<object> GetStatusAsync(IConsulRegistration registration)

Parameters

registration IConsulRegistration

the registration to register

Returns

Task<object>

the status value

GetStatusAsyncInternal(IConsulRegistration)

public Task<object> GetStatusAsyncInternal(IConsulRegistration registration)

Parameters

registration IConsulRegistration

Returns

Task<object>

GetStatus<S>(IConsulRegistration)

Return the current status of the service registry registration

public S GetStatus<S>(IConsulRegistration registration) where S : class

Parameters

registration IConsulRegistration

the service registration to obtain status for

Returns

S

the returned status

Type Parameters

S

the status

Register(IConsulRegistration)

Register a service instance in the service registry

public void Register(IConsulRegistration registration)

Parameters

registration IConsulRegistration

the service instance to register

RegisterAsync(IConsulRegistration)

Register the provided registration in Consul

public Task RegisterAsync(IConsulRegistration registration)

Parameters

registration IConsulRegistration

the 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

registration IConsulRegistration

the registration to update

status string

the status

SetStatusAsync(IConsulRegistration, string)

Set the status of the registration in Consul

public Task SetStatusAsync(IConsulRegistration registration, string status)

Parameters

registration IConsulRegistration

the registration to register

status string

the status value to set

Returns

Task

the task