JetstreamHealthIndicator
@horizon-republic/nestjs-jetstream
@horizon-republic/nestjs-jetstream / JetstreamHealthIndicator
JetstreamHealthIndicator
Defined in: src/health/jetstream.health-indicator.ts:30
Health indicator result compatible with @nestjs/terminus.
Follows the Terminus convention: returns status object on success, throws on failure. Works with Terminus out of the box, no wrapper needed:
Example
// With Terminus
this.health.check([() => this.jetstream.isHealthy()])
// Standalone
const status = await this.jetstream.check();
Constructors
Constructor
new JetstreamHealthIndicator(
registry):JetstreamHealthIndicator
Defined in: src/health/jetstream.health-indicator.ts:33
Parameters
registry
ConnectionRegistry
Returns
JetstreamHealthIndicator
Methods
check()
check():
Promise<JetstreamHealthStatus>
Defined in: src/health/jetstream.health-indicator.ts:46
Plain health status check.
Returns the current connection status without throwing. connected means
every critical connection is alive; degraded means at least one
non-critical connection is not. With a single connection the
multi-connection fields are omitted entirely, so the response shape is
unchanged from before named connections existed.
Returns
Promise<JetstreamHealthStatus>
Connection status with server URL and RTT latency.
isHealthy()
isHealthy(
key?):Promise<JetstreamHealthIndicatorResult>
Defined in: src/health/jetstream.health-indicator.ts:132
Terminus-compatible health check.
Returns { [key]: { status: 'up', ... } } on success.
Throws an error with { [key]: { status: 'down', ... } } on failure.
Throws only when a critical connection is down, so a dead secondary cluster degrades the report without failing readiness.
The thrown error sets isHealthCheckError: true and causes, the
duck-type contract that Terminus HealthCheckExecutor uses to distinguish
health failures from unexpected exceptions. Works with both Terminus v10
(instanceof HealthCheckError) and v11+ (error?.isHealthCheckError).
Parameters
key?
string = 'jetstream'
Health indicator key (default: 'jetstream').
Returns
Promise<JetstreamHealthIndicatorResult>
Object with status, server, and latency under the given key.
Throws
Error with isHealthCheckError, causes, and { [key]: { status: 'down' } }.