Connectum API Reference / @connectum/events-nats / types / NatsLifecycleEvent
Type Alias: NatsLifecycleEvent ​
NatsLifecycleEvent = {
reconnected:boolean;server?:string;type:"connected"; } | {server:string;type:"disconnected"; } | {attempt:number;type:"reconnecting"; } | {error:Error;type:"reconnect-failed"; } | {callback:string;error:Error;event:string;type:"lifecycle-error"; }
Defined in: types.ts:82
Connection lifecycle events of the NATS adapter, delivered to NatsLifecycleCallbacks.onLifecycle.
A discriminated union on type. The strings and the shared fields match the AMQP adapter's events; the type is local to this package. Without the callback the adapter attaches no listener to the client.
Union Members ​
Type Literal ​
{ reconnected: boolean; server?: string; type: "connected"; }
reconnected ​
readonlyreconnected:boolean
server? ​
readonlyoptionalserver?:string
The server reached again; set only for a recovery.
type ​
readonlytype:"connected"
Delivered once after the first connect (reconnected: false) and once per recovery (reconnected: true).
Type Literal ​
{ server: string; type: "disconnected"; }
server ​
readonlyserver:string
type ​
readonlytype:"disconnected"
The connection to the server was lost; the client tries to reconnect on its own. Not delivered for disconnect().
Type Literal ​
{ attempt: number; type: "reconnecting"; }
attempt ​
readonlyattempt:number
type ​
readonlytype:"reconnecting"
The client dials a server again. attempt counts dials since the loss (the client reports one per address it tries, not one per round); the client reports no delay or error, so none is given.
Type Literal ​
{ error: Error; type: "reconnect-failed"; }
error ​
readonlyerror:Error
type ​
readonlytype:"reconnect-failed"
Terminal: the client closed itself without a disconnect() call, typically after its reconnect budget ran out. The adapter drops the dead connection, so connect() can start a new one.
Type Literal ​
{ callback: string; error: Error; event: string; type: "lifecycle-error"; }
callback ​
readonlycallback:string
error ​
readonlyerror:Error
event ​
readonlyevent:string
type ​
readonlytype:"lifecycle-error"
A lifecycle callback threw or returned a rejected promise.