interface ServiceInstance
Since 0.2.0

One reachable instance of a service.

Providers normalize their backend's own shape into this — a Consul health entry, a Kubernetes EndpointSlice endpoint, a DNS SRV record, and a literal static entry all arrive here identically.

Properties

readonly
id: string

Instance identity, unique within the service.

Used as the ejection tracker's key, so it must be stable across resolves for ejection to survive a cache refresh.

readonly
serviceName: string

The logical service this instance belongs to.

readonly
host: string

Hostname or IP literal. IPv6 literals arrive unbracketed.

readonly
port: number

TCP port.

readonly
optional
secure: boolean

Whether the instance speaks TLS, deciding the https scheme.

readonly
optional
weight: number

Relative selection weight for the 'weighted-random' strategy.

Absent means 1. A non-positive weight is never selected unless every instance is non-positive, in which case selection falls back to uniform.

readonly
optional
tags: readonly string[]

Free-form labels the backend carries (Consul tags, for example).

readonly
optional
metadata: Readonly<Record<string, string>>

Free-form key/value metadata the backend carries.

Usage

import { type ServiceInstance } from "common/src/index.ts";