Skip to main content

Function: openConsumer()

openConsumer(nc, stream, consumer): Promise<Consumer>

Defined in: packages/messaging/src/stream-check.ts:178

What a reading service calls at start: checks that its stream and its durable consumer exist and are configured exactly as declared, then returns the consumer to pull from. It creates and changes nothing, and needs only STREAM.INFO and CONSUMER.INFO for that (the permission table grants the reader no more).

Parameters​

nc​

NatsConnection

A connection as the consumer's host principal.

stream​

"AUDIT" | "GOVERNANCE" | "TRUST" | "PROVISIONING" | "PLACEMENT" | "ISSUANCE"

consumer​

string

The durable consumer's name.

Returns​

Promise<Consumer>

The consumer.

Throws​

The stream or the consumer has not been declared yet.

Throws​

Either is configured otherwise. Do not run on it.

Throws​

The broker refused (permissions) or is unreachable.