class StaticProvider
implements DiscoveryProvider
Since 0.2.0

Serves a configured instance list.

Constructors

StaticProvider(
services: Readonly<Record<string, readonly StaticServiceDefinition[]>>,
runtime: IRuntimeServices
)
Parameters
services: Readonly<Record<string, readonly StaticServiceDefinition[]>>

Service name to its instances

runtime: IRuntimeServices

Supplies the timer used to deliver the first watch event

Properties

readonly
kind: string

Backend id.

Methods

isHealthy(): Promise<boolean>

M70c: a static map is in memory and cannot be unreachable, so it is always reachable (M47).

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

Reads the current instance list for a service.

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

Fires once with the configured list and never again.

The list is immutable by construction, so there is nothing further to report. Delivering it on a timer rather than synchronously means a caller that subscribes and then reads has the same ordering it would get from a real backend.

Usage

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