class DnsProvider
implements DiscoveryProvider
Since 0.2.0

Resolves services through DNS.

Constructors

DnsProvider(
resolver: IDnsResolver,
runtime: IRuntimeServices,
)
Parameters
resolver: IDnsResolver

The DNS resolver from IRuntimeServices.dns

runtime: IRuntimeServices

Supplies timers for the poll

Mode, template, port, and poll interval

Properties

readonly
kind: string

Backend id.

Methods

domainFor(serviceName: string): string

Substitutes the service name into the configured template.

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

Reads the current instance list for a service.

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

Polls at watchIntervalMs, firing only when the instance list changed.

DNS has no push channel. Polling is the honest implementation: a watch() that never fires would be worse than a documented interval.

Usage

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