@nats-io/nats-core
Advanced tools
Comparing version 3.0.0-38 to 3.0.0-39
@@ -1,27 +0,41 @@ | ||
/** | ||
* Events reported by the {@link NatsConnection#status} iterator. | ||
*/ | ||
export declare enum Events { | ||
/** Client disconnected */ | ||
Disconnect = "disconnect", | ||
/** Client reconnected */ | ||
Reconnect = "reconnect", | ||
/** Client received a cluster update */ | ||
Update = "update", | ||
/** Client received a signal telling it that the server is transitioning to Lame Duck Mode */ | ||
LDM = "ldm", | ||
/** Client received an async error from the server */ | ||
Error = "error" | ||
} | ||
/** | ||
* Other events that can be reported by the {@link NatsConnection#status} iterator. | ||
* These can usually be safely ignored, as higher-order functionality of the client | ||
* will handle them. | ||
*/ | ||
export declare enum DebugEvents { | ||
Reconnecting = "reconnecting", | ||
PingTimer = "pingTimer", | ||
StaleConnection = "staleConnection", | ||
ClientInitiatedReconnect = "client initiated reconnect" | ||
} | ||
export type DisconnectStatus = { | ||
type: "disconnect"; | ||
server: string; | ||
}; | ||
export type ReconnectStatus = { | ||
type: "reconnect"; | ||
server: string; | ||
}; | ||
export type ReconnectingStatus = { | ||
type: "reconnecting"; | ||
}; | ||
export type ClusterUpdateStatus = { | ||
type: "update"; | ||
added?: string[]; | ||
deleted?: string[]; | ||
}; | ||
export type LDMStatus = { | ||
type: "ldm"; | ||
server: string; | ||
}; | ||
export type ServerErrorStatus = { | ||
type: "error"; | ||
error: Error; | ||
}; | ||
export type ClientPingStatus = { | ||
type: "ping"; | ||
pendingPings: number; | ||
}; | ||
export type StaleConnectionStatus = { | ||
type: "staleConnection"; | ||
}; | ||
export type ForceReconnectStatus = { | ||
type: "forceReconnect"; | ||
}; | ||
export type SlowConsumerStatus = { | ||
type: "slowConsumer"; | ||
sub: Subscription; | ||
pending: number; | ||
}; | ||
export type Status = DisconnectStatus | ReconnectStatus | ReconnectingStatus | ClusterUpdateStatus | LDMStatus | ServerErrorStatus | ClientPingStatus | StaleConnectionStatus | SlowConsumerStatus | ForceReconnectStatus; | ||
export type MsgCallback<T> = (err: Error | null, msg: T) => void; | ||
@@ -56,2 +70,10 @@ /** | ||
callback?: MsgCallback<T>; | ||
/** | ||
* Number of pending messages in a subscription to exceed prior to considering | ||
* a subscription a Slow Consumer. By default, slow consumer is on a subscription | ||
* is not accounted for. | ||
* | ||
* This is an experimental option. | ||
*/ | ||
slow?: number; | ||
} | ||
@@ -61,11 +83,2 @@ export interface DnsResolveFn { | ||
} | ||
export interface Status { | ||
type: Events | DebugEvents; | ||
data: string | ServersChanged | number; | ||
error?: Error; | ||
permissionContext?: { | ||
operation: string; | ||
subject: string; | ||
}; | ||
} | ||
/** | ||
@@ -72,0 +85,0 @@ * Subscription Options |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_HOST = exports.DEFAULT_PORT = exports.RequestStrategy = exports.Match = exports.DebugEvents = exports.Events = void 0; | ||
exports.DEFAULT_HOST = exports.DEFAULT_PORT = exports.RequestStrategy = exports.Match = void 0; | ||
exports.syncIterator = syncIterator; | ||
@@ -23,30 +23,2 @@ exports.createInbox = createInbox; | ||
const errors_1 = require("./errors"); | ||
/** | ||
* Events reported by the {@link NatsConnection#status} iterator. | ||
*/ | ||
var Events; | ||
(function (Events) { | ||
/** Client disconnected */ | ||
Events["Disconnect"] = "disconnect"; | ||
/** Client reconnected */ | ||
Events["Reconnect"] = "reconnect"; | ||
/** Client received a cluster update */ | ||
Events["Update"] = "update"; | ||
/** Client received a signal telling it that the server is transitioning to Lame Duck Mode */ | ||
Events["LDM"] = "ldm"; | ||
/** Client received an async error from the server */ | ||
Events["Error"] = "error"; | ||
})(Events || (exports.Events = Events = {})); | ||
/** | ||
* Other events that can be reported by the {@link NatsConnection#status} iterator. | ||
* These can usually be safely ignored, as higher-order functionality of the client | ||
* will handle them. | ||
*/ | ||
var DebugEvents; | ||
(function (DebugEvents) { | ||
DebugEvents["Reconnecting"] = "reconnecting"; | ||
DebugEvents["PingTimer"] = "pingTimer"; | ||
DebugEvents["StaleConnection"] = "staleConnection"; | ||
DebugEvents["ClientInitiatedReconnect"] = "client initiated reconnect"; | ||
})(DebugEvents || (exports.DebugEvents = DebugEvents = {})); | ||
var Match; | ||
@@ -53,0 +25,0 @@ (function (Match) { |
@@ -19,3 +19,2 @@ "use strict"; | ||
const util_1 = require("./util"); | ||
const core_1 = require("./core"); | ||
class Heartbeat { | ||
@@ -55,3 +54,3 @@ ph; | ||
this.timer = setTimeout(() => { | ||
this.ph.dispatchStatus({ type: core_1.DebugEvents.PingTimer, data: `${this.pendings.length + 1}` }); | ||
this.ph.dispatchStatus({ type: "ping", pendingPings: this.pendings.length + 1 }); | ||
if (this.pendings.length === this.maxOut) { | ||
@@ -58,0 +57,0 @@ this.cancel(true); |
@@ -32,3 +32,3 @@ export { NatsConnectionImpl } from "./nats"; | ||
export type { Auth, Authenticator, CallbackFn, ConnectionOptions, Dispatcher, JwtAuth, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Publisher, PublishOptions, QueuedIterator, Request, RequestManyOptions, RequestOptions, ReviverFn, Server, ServerInfo, ServersChanged, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, TlsOptions, TokenAuth, UserPass, } from "./core"; | ||
export { createInbox, DebugEvents, Events, Match, RequestStrategy, syncIterator, } from "./core"; | ||
export { createInbox, Match, RequestStrategy, syncIterator } from "./core"; | ||
export { SubscriptionImpl, Subscriptions } from "./protocol"; | ||
@@ -35,0 +35,0 @@ export type { IdleHeartbeatFn, IdleHeartbeatOptions, } from "./idleheartbeat_monitor"; |
@@ -32,3 +32,3 @@ "use strict"; | ||
exports.TD = exports.Metric = exports.Bench = exports.writeAll = exports.readAll = exports.MAX_SIZE = exports.DenoBuffer = exports.State = exports.Parser = exports.Kind = exports.QueuedIteratorImpl = exports.usernamePasswordAuthenticator = exports.tokenAuthenticator = exports.nkeyAuthenticator = exports.jwtAuthenticator = exports.credsAuthenticator = exports.RequestOne = exports.parseOptions = exports.hasWsProtocol = exports.defaultOptions = exports.DEFAULT_MAX_RECONNECT_ATTEMPTS = exports.checkUnsupportedOption = exports.checkOptions = exports.buildAuthenticator = exports.DataBuffer = exports.MuxSubscription = exports.Heartbeat = exports.MsgHdrsImpl = exports.headers = exports.canonicalMIMEHeaderKey = exports.timeout = exports.SimpleMutex = exports.render = exports.nanos = exports.millis = exports.extend = exports.delay = exports.deferred = exports.deadline = exports.collect = exports.backoff = exports.ProtocolHandler = exports.INFO = exports.Connect = exports.setTransportFactory = exports.getResolveFn = exports.MsgImpl = exports.nuid = exports.Nuid = exports.NatsConnectionImpl = void 0; | ||
exports.UserAuthenticationExpiredError = exports.TimeoutError = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.NoRespondersError = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.errors = exports.DrainingConnectionError = exports.ConnectionError = exports.ClosedConnectionError = exports.AuthorizationError = exports.wsUrlParseFn = exports.wsconnect = exports.SHA256 = exports.Base64UrlPaddedCodec = exports.Base64UrlCodec = exports.Base64Codec = exports.Servers = exports.isIPV4OrHostname = exports.IdleHeartbeatMonitor = exports.Subscriptions = exports.SubscriptionImpl = exports.syncIterator = exports.RequestStrategy = exports.Match = exports.Events = exports.DebugEvents = exports.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = exports.TE = void 0; | ||
exports.UserAuthenticationExpiredError = exports.TimeoutError = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.NoRespondersError = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.errors = exports.DrainingConnectionError = exports.ConnectionError = exports.ClosedConnectionError = exports.AuthorizationError = exports.wsUrlParseFn = exports.wsconnect = exports.SHA256 = exports.Base64UrlPaddedCodec = exports.Base64UrlCodec = exports.Base64Codec = exports.Servers = exports.isIPV4OrHostname = exports.IdleHeartbeatMonitor = exports.Subscriptions = exports.SubscriptionImpl = exports.syncIterator = exports.RequestStrategy = exports.Match = exports.createInbox = exports.protoLen = exports.extractProtocolMessage = exports.Empty = exports.parseSemVer = exports.Features = exports.Feature = exports.compare = exports.parseIP = exports.isIP = exports.ipV4 = exports.TE = void 0; | ||
var nats_1 = require("./nats"); | ||
@@ -120,4 +120,2 @@ Object.defineProperty(exports, "NatsConnectionImpl", { enumerable: true, get: function () { return nats_1.NatsConnectionImpl; } }); | ||
Object.defineProperty(exports, "createInbox", { enumerable: true, get: function () { return core_1.createInbox; } }); | ||
Object.defineProperty(exports, "DebugEvents", { enumerable: true, get: function () { return core_1.DebugEvents; } }); | ||
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return core_1.Events; } }); | ||
Object.defineProperty(exports, "Match", { enumerable: true, get: function () { return core_1.Match; } }); | ||
@@ -124,0 +122,0 @@ Object.defineProperty(exports, "RequestStrategy", { enumerable: true, get: function () { return core_1.RequestStrategy; } }); |
@@ -1,2 +0,2 @@ | ||
export { AuthorizationError, backoff, Bench, buildAuthenticator, canonicalMIMEHeaderKey, ClosedConnectionError, ConnectionError, createInbox, credsAuthenticator, deadline, DebugEvents, deferred, delay, DrainingConnectionError, Empty, errors, Events, hasWsProtocol, headers, InvalidArgumentError, InvalidOperationError, InvalidSubjectError, jwtAuthenticator, Match, Metric, millis, MsgHdrsImpl, nanos, nkeyAuthenticator, nkeys, NoRespondersError, Nuid, nuid, PermissionViolationError, ProtocolError, RequestError, RequestStrategy, syncIterator, TimeoutError, tokenAuthenticator, UserAuthenticationExpiredError, usernamePasswordAuthenticator, wsconnect, } from "./internal_mod"; | ||
export { AuthorizationError, backoff, Bench, buildAuthenticator, canonicalMIMEHeaderKey, ClosedConnectionError, ConnectionError, createInbox, credsAuthenticator, deadline, deferred, delay, DrainingConnectionError, Empty, errors, hasWsProtocol, headers, InvalidArgumentError, InvalidOperationError, InvalidSubjectError, jwtAuthenticator, Match, Metric, millis, MsgHdrsImpl, nanos, nkeyAuthenticator, nkeys, NoRespondersError, Nuid, nuid, PermissionViolationError, ProtocolError, RequestError, RequestStrategy, syncIterator, TimeoutError, tokenAuthenticator, UserAuthenticationExpiredError, usernamePasswordAuthenticator, wsconnect, } from "./internal_mod"; | ||
export type { Auth, Authenticator, Backoff, BenchOpts, Codec, ConnectionOptions, Deferred, Delay, JwtAuth, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Perf, Publisher, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ReviverFn, ServerInfo, ServersChanged, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, Timeout, TlsOptions, TokenAuth, UserPass, } from "./internal_mod"; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.wsconnect = exports.usernamePasswordAuthenticator = exports.UserAuthenticationExpiredError = exports.tokenAuthenticator = exports.TimeoutError = exports.syncIterator = exports.RequestStrategy = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.nuid = exports.Nuid = exports.NoRespondersError = exports.nkeys = exports.nkeyAuthenticator = exports.nanos = exports.MsgHdrsImpl = exports.millis = exports.Metric = exports.Match = exports.jwtAuthenticator = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.headers = exports.hasWsProtocol = exports.Events = exports.errors = exports.Empty = exports.DrainingConnectionError = exports.delay = exports.deferred = exports.DebugEvents = exports.deadline = exports.credsAuthenticator = exports.createInbox = exports.ConnectionError = exports.ClosedConnectionError = exports.canonicalMIMEHeaderKey = exports.buildAuthenticator = exports.Bench = exports.backoff = exports.AuthorizationError = void 0; | ||
exports.wsconnect = exports.usernamePasswordAuthenticator = exports.UserAuthenticationExpiredError = exports.tokenAuthenticator = exports.TimeoutError = exports.syncIterator = exports.RequestStrategy = exports.RequestError = exports.ProtocolError = exports.PermissionViolationError = exports.nuid = exports.Nuid = exports.NoRespondersError = exports.nkeys = exports.nkeyAuthenticator = exports.nanos = exports.MsgHdrsImpl = exports.millis = exports.Metric = exports.Match = exports.jwtAuthenticator = exports.InvalidSubjectError = exports.InvalidOperationError = exports.InvalidArgumentError = exports.headers = exports.hasWsProtocol = exports.errors = exports.Empty = exports.DrainingConnectionError = exports.delay = exports.deferred = exports.deadline = exports.credsAuthenticator = exports.createInbox = exports.ConnectionError = exports.ClosedConnectionError = exports.canonicalMIMEHeaderKey = exports.buildAuthenticator = exports.Bench = exports.backoff = exports.AuthorizationError = void 0; | ||
var internal_mod_1 = require("./internal_mod"); | ||
@@ -30,3 +30,2 @@ Object.defineProperty(exports, "AuthorizationError", { enumerable: true, get: function () { return internal_mod_1.AuthorizationError; } }); | ||
Object.defineProperty(exports, "deadline", { enumerable: true, get: function () { return internal_mod_1.deadline; } }); | ||
Object.defineProperty(exports, "DebugEvents", { enumerable: true, get: function () { return internal_mod_1.DebugEvents; } }); | ||
Object.defineProperty(exports, "deferred", { enumerable: true, get: function () { return internal_mod_1.deferred; } }); | ||
@@ -37,3 +36,2 @@ Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return internal_mod_1.delay; } }); | ||
Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return internal_mod_1.errors; } }); | ||
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return internal_mod_1.Events; } }); | ||
Object.defineProperty(exports, "hasWsProtocol", { enumerable: true, get: function () { return internal_mod_1.hasWsProtocol; } }); | ||
@@ -40,0 +38,0 @@ Object.defineProperty(exports, "headers", { enumerable: true, get: function () { return internal_mod_1.headers; } }); |
@@ -104,2 +104,11 @@ "use strict"; | ||
const sub = new protocol_1.SubscriptionImpl(this.protocol, subject, opts); | ||
if (typeof opts.callback !== "function" && typeof opts.slow === "number") { | ||
sub.setSlowNotificationFn(opts.slow, (pending) => { | ||
this.protocol.dispatchStatus({ | ||
type: "slowConsumer", | ||
sub, | ||
pending, | ||
}); | ||
}); | ||
} | ||
this.protocol.subscribe(sub); | ||
@@ -106,0 +115,0 @@ return sub; |
@@ -37,2 +37,9 @@ import type { Transport } from "./transport"; | ||
} | ||
declare class SlowNotifier { | ||
slow: number; | ||
cb: (pending: number) => void; | ||
notified: boolean; | ||
constructor(slow: number, cb: (pending: number) => void); | ||
maybeNotify(pending: number): void; | ||
} | ||
export declare class SubscriptionImpl extends QueuedIteratorImpl<Msg> implements Subscription { | ||
@@ -51,3 +58,5 @@ sid: number; | ||
requestSubject?: string; | ||
slow?: SlowNotifier; | ||
constructor(protocol: ProtocolHandler, subject: string, opts?: SubscriptionOptions); | ||
setSlowNotificationFn(slow: number, fn?: (pending: number) => void): void; | ||
callback(err: Error | null, msg: Msg): void; | ||
@@ -154,1 +163,2 @@ close(): void; | ||
} | ||
export {}; |
@@ -29,3 +29,2 @@ "use strict"; | ||
const semver_1 = require("./semver"); | ||
const core_1 = require("./core"); | ||
const options_1 = require("./options"); | ||
@@ -70,2 +69,25 @@ const errors_1 = require("./errors"); | ||
exports.Connect = Connect; | ||
class SlowNotifier { | ||
slow; | ||
cb; | ||
notified; | ||
constructor(slow, cb) { | ||
this.slow = slow; | ||
this.cb = cb; | ||
this.notified = false; | ||
} | ||
maybeNotify(pending) { | ||
// if we are below the threshold reset the ability to notify | ||
if (pending <= this.slow) { | ||
this.notified = false; | ||
} | ||
else { | ||
if (!this.notified) { | ||
// crossed the threshold, notify and silence. | ||
this.cb(pending); | ||
this.notified = true; | ||
} | ||
} | ||
} | ||
} | ||
class SubscriptionImpl extends queued_iterator_1.QueuedIteratorImpl { | ||
@@ -84,2 +106,3 @@ sid; | ||
requestSubject; | ||
slow; | ||
constructor(protocol, subject, opts = {}) { | ||
@@ -118,5 +141,17 @@ super(); | ||
} | ||
setSlowNotificationFn(slow, fn) { | ||
this.slow = undefined; | ||
if (fn) { | ||
if (this.noIterator) { | ||
throw new Error("callbacks don't support slow notifications"); | ||
} | ||
this.slow = new SlowNotifier(slow, fn); | ||
} | ||
} | ||
callback(err, msg) { | ||
this.cancelTimeout(); | ||
err ? this.stop(err) : this.push(msg); | ||
if (!err && this.slow) { | ||
this.slow.maybeNotify(this.getPending()); | ||
} | ||
} | ||
@@ -383,3 +418,3 @@ close() { | ||
disconnect() { | ||
this.dispatchStatus({ type: core_1.DebugEvents.StaleConnection, data: "" }); | ||
this.dispatchStatus({ type: "staleConnection" }); | ||
this.transport.disconnect(); | ||
@@ -390,4 +425,3 @@ } | ||
this.dispatchStatus({ | ||
type: core_1.DebugEvents.ClientInitiatedReconnect, | ||
data: "", | ||
type: "forceReconnect", | ||
}); | ||
@@ -400,4 +434,4 @@ this.transport.disconnect(); | ||
this.dispatchStatus({ | ||
type: core_1.Events.Disconnect, | ||
data: this.servers.getCurrentServer().toString(), | ||
type: "disconnect", | ||
server: this.servers.getCurrentServer().toString(), | ||
}); | ||
@@ -408,4 +442,4 @@ if (this.options.reconnect) { | ||
this.dispatchStatus({ | ||
type: core_1.Events.Reconnect, | ||
data: this.servers.getCurrentServer().toString(), | ||
type: "reconnect", | ||
server: this.servers.getCurrentServer().toString(), | ||
}); | ||
@@ -479,3 +513,3 @@ // if we are here we reconnected, but we have an authentication | ||
lastErr = null; | ||
this.dispatchStatus({ type: core_1.DebugEvents.Reconnecting, data: a.toString() }); | ||
this.dispatchStatus({ type: "reconnecting" }); | ||
await this.dial(a); | ||
@@ -615,3 +649,3 @@ // if here we connected | ||
} | ||
this.dispatchStatus({ type: core_1.Events.Error, error: err, data: err.message }); | ||
this.dispatchStatus({ type: "error", error: err }); | ||
this.handleError(err); | ||
@@ -680,3 +714,4 @@ } | ||
if (updates) { | ||
this.dispatchStatus({ type: core_1.Events.Update, data: updates }); | ||
const { added, deleted } = updates; | ||
this.dispatchStatus({ type: "update", added, deleted }); | ||
} | ||
@@ -686,4 +721,4 @@ const ldm = info.ldm !== undefined ? info.ldm : false; | ||
this.dispatchStatus({ | ||
type: core_1.Events.LDM, | ||
data: this.servers.getCurrentServer().toString(), | ||
type: "ldm", | ||
server: this.servers.getCurrentServer().toString(), | ||
}); | ||
@@ -690,0 +725,0 @@ } |
@@ -112,3 +112,3 @@ "use strict"; | ||
this.set(Feature.JS_BATCH_DIRECT_GET, "2.11.0"); | ||
this.set(Feature.JS_PRIORITY_GROUPS, "2.12.0"); | ||
this.set(Feature.JS_PRIORITY_GROUPS, "2.11.0"); | ||
this.disabled.forEach((f) => { | ||
@@ -115,0 +115,0 @@ this.features.delete(f); |
@@ -1,1 +0,1 @@ | ||
export declare const version = "3.0.0-38"; | ||
export declare const version = "3.0.0-39"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is generated - do not edit | ||
exports.version = "3.0.0-38"; | ||
exports.version = "3.0.0-39"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@nats-io/nats-core", | ||
"version": "3.0.0-38", | ||
"version": "3.0.0-39", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "lib/", |
@@ -767,29 +767,25 @@ # Core | ||
### Lifecycle/Informational Events | ||
### Lifecycle and Informational Events | ||
Clients can get notification on various event types: | ||
Clients can get notification on various event types by calling | ||
`status(): AsyncIterable<Status>` on the connection, the currently included | ||
status `type`s include: | ||
- `Events.DISCONNECT` | ||
- `Events.RECONNECT` | ||
- `Events.UPDATE` | ||
- `Events.LDM` | ||
- `Events.ERROR` | ||
- `disconnect` - the client disconnected from the specified `server` | ||
- `reconnect` - the client reconnected to the specified `server` | ||
- `reconnecting` - the client is in its reconnect loop | ||
- `update` - the cluster configuration has been updated, if servers were added | ||
the `added` list will specify them, if servers were deleted servers the | ||
`deleted` list will specify them. | ||
- `ldm` - the server has started its lame duck mode and will evict clients | ||
- `error` - an async error (such as a permission violation) was received, the | ||
error is specified in the `error` property. Note that permission errors for | ||
subscriptions are also notified to the subscription. | ||
- `ping` - the server has not received a response for client pings, the number | ||
of outstanding pings are notified in the `pendingPings` property. Note that | ||
this should onlyl be `1` under normal operations. | ||
- `staleConnection` - the connection is stale (client will reconnect) | ||
- `forceReconnect` - the client has been instructed to reconnect because of | ||
user-code (`reconnect()`) | ||
The first two fire when a client disconnects and reconnects respectively. The | ||
payload will be the server where the event took place. | ||
The `UPDATE` event notifies whenever the client receives a cluster configuration | ||
update. The `ServersChanged` interface provides two arrays: `added` and | ||
`deleted` listing the servers that were added or removed. | ||
The `LDM` event notifies that the current server has signaled that it is running | ||
in _Lame Duck Mode_ and will evict clients. Depending on the server | ||
configuration policy, the client may want to initiate an ordered shutdown, and | ||
initiate a new connection to a different server in the cluster. | ||
The `ERROR` event notifies you of async errors that couldn't be routed in a more | ||
precise way to your client. For example, permission errors for a subscription or | ||
request, will properly be reported by the subscription or request. However, | ||
permission errors on publish will be reported via the status mechanism. | ||
```javascript | ||
@@ -800,3 +796,10 @@ const nc = await connect(opts); | ||
for await (const s of nc.status()) { | ||
console.info(`${s.type}: ${s.data}`); | ||
switch (s.type) { | ||
case "disconnect": | ||
case "reconnect": | ||
console.log(s); | ||
break; | ||
default: | ||
// ignored | ||
} | ||
} | ||
@@ -803,0 +806,0 @@ })().then(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
542366
8530
919