method DiscoveryProvider.watch
DiscoveryProvider.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.

Parameters

serviceName: string

Logical service name

listener: (instances: readonly ServiceInstance[]) => void

Called with the full instance list on every change

Return Type

Promise<Unsubscribe>

Unsubscribe function that stops the underlying watch

Usage

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