interface DiscoveryProvider
Since 0.2.0

A discovery backend.

The plugin's caching, balancing, and ejection all sit above this port, so a provider only has to answer "who is running this service" and, where its backend supports it, "tell me when that changes".

Properties

readonly
kind: string

Backend id, surfaced by the health indicator.

Methods

resolve(serviceName: string): Promise<readonly ServiceInstance[]>

Reads the current instance list for a service.

watch(
serviceName: string,
listener: (instances: readonly ServiceInstance[]) => void
): Promise<Unsubscribe>

Subscribes to instance-list changes.

Push-based where the backend supports it, interval-polled where it does not. The listener always receives the full list.

optional
registerSelf(registration: SelfRegistration): Promise<void>

Registers this application instance with the backend.

Present only on providers with a registration API (Consul).

optional
deregisterSelf(registration: SelfRegistration): Promise<void>

Removes this application instance from the backend.

Since 0.2.0
optional
isHealthy(): Promise<boolean>

M70c: reports whether the discovery backend is reachable right now, for the plugin's health indicator.

Optional: a provider with no meaningful liveness check omits it, and the indicator then relies on the service's everResolved state. This answers a fact (reachability), not a policy: the indicator owns the up/degraded/ down mapping.

Usage

import { type DiscoveryProvider } from "service-discovery-plugin/src/index.ts";