Interface IDiscoveryClient
Provides access to remote service instances using a discovery server.
Namespace: Steeltoe.Common.Discovery
Assembly: Steeltoe.Common.dll
Syntax
public interface IDiscoveryClient
Properties
| Edit this page View SourceDescription
Gets a human-readable description of this discovery client.
Declaration
string Description { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Edit this page View SourceGetInstancesAsync(String, CancellationToken)
Gets all service instances associated with the specified service ID from the discovery server.
Declaration
Task<IList<IServiceInstance>> GetInstancesAsync(string serviceId, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | serviceId | The ID of the service to lookup. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<IList<IServiceInstance>> | The list of remote service instances. |
GetLocalServiceInstance()
Gets information used to register the local service instance (this app) to the discovery server.
Declaration
IServiceInstance GetLocalServiceInstance()
Returns
Type | Description |
---|---|
IServiceInstance | The service instance that represents this app, or |
GetServiceIdsAsync(CancellationToken)
Gets all registered service IDs from the discovery server.
Declaration
Task<ISet<string>> GetServiceIdsAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<ISet<System.String>> | The list of service IDs. |
ShutdownAsync(CancellationToken)
Deregisters the local service (this app) from the discovery server.
Declaration
Task ShutdownAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |
Remarks
This method exists for two reasons, instead of just reusing IHttpClientFactory
, it requires the IoC container to obtain an DiscoveryClientHostedService
in the IoC container, which is a
hosted service that performs deregistration (by calling this method) when the app is terminating. At that time, the IoC container is still
accessible.