@nats-io/nats-core
Advanced tools
Comparing version 3.0.0-40 to 3.0.0-41
@@ -622,3 +622,3 @@ export type DisconnectStatus = { | ||
* Sets the maximum count of ping commands that can be awaiting a response | ||
* before rasing a stale connection status {@link DebugEvents#StaleConnection } | ||
* before raising a stale connection status {@link StaleConnectionStatus } | ||
* notification {@link NatsConnection#status} and initiating a reconnect. | ||
@@ -625,0 +625,0 @@ * |
@@ -31,3 +31,3 @@ export { NatsConnectionImpl } from "./nats"; | ||
export { extractProtocolMessage, protoLen } from "./transport"; | ||
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 type { Auth, Authenticator, CallbackFn, ClientPingStatus, ClusterUpdateStatus, ConnectionOptions, DisconnectStatus, Dispatcher, ForceReconnectStatus, JwtAuth, LDMStatus, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Publisher, PublishOptions, QueuedIterator, ReconnectingStatus, ReconnectStatus, Request, RequestManyOptions, RequestOptions, ReviverFn, Server, ServerErrorStatus, ServerInfo, ServersChanged, SlowConsumerStatus, StaleConnectionStatus, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, TlsOptions, TokenAuth, UserPass, } from "./core"; | ||
export { createInbox, Match, RequestStrategy, syncIterator } from "./core"; | ||
@@ -34,0 +34,0 @@ export { SubscriptionImpl, Subscriptions } from "./protocol"; |
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"; | ||
export type { Auth, Authenticator, Backoff, BenchOpts, ClientPingStatus, ClusterUpdateStatus, Codec, ConnectionOptions, Deferred, Delay, DisconnectStatus, ForceReconnectStatus, JwtAuth, LDMStatus, Msg, MsgCallback, MsgHdrs, Nanos, NatsConnection, NKeyAuth, NoAuth, Payload, Perf, Publisher, PublishOptions, QueuedIterator, ReconnectingStatus, ReconnectStatus, RequestManyOptions, RequestOptions, ReviverFn, ServerErrorStatus, ServerInfo, ServersChanged, SlowConsumerStatus, StaleConnectionStatus, Stats, Status, SubOpts, Subscription, SubscriptionOptions, SyncIterator, Timeout, TlsOptions, TokenAuth, UserPass, } from "./internal_mod"; |
import { ProtocolHandler } from "./protocol"; | ||
import type { Features, SemVer } from "./semver"; | ||
import type { ConnectionOptions, Context, Dispatcher, Msg, NatsConnection, Payload, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from "./core"; | ||
import type { ConnectionOptions, Context, Msg, NatsConnection, Payload, PublishOptions, QueuedIterator, RequestManyOptions, RequestOptions, ServerInfo, Stats, Status, Subscription, SubscriptionOptions } from "./core"; | ||
export declare class NatsConnectionImpl implements NatsConnection { | ||
@@ -8,3 +8,2 @@ options: ConnectionOptions; | ||
draining: boolean; | ||
listeners: Dispatcher<Status>[]; | ||
private constructor(); | ||
@@ -11,0 +10,0 @@ static connect(opts?: ConnectionOptions): Promise<NatsConnection>; |
@@ -31,7 +31,5 @@ "use strict"; | ||
draining; | ||
listeners; | ||
constructor(opts) { | ||
this.draining = false; | ||
this.options = (0, options_1.parseOptions)(opts); | ||
this.listeners = []; | ||
} | ||
@@ -44,9 +42,2 @@ static connect(opts = {}) { | ||
nc.protocol = ph; | ||
(async function () { | ||
for await (const s of ph.status()) { | ||
nc.listeners.forEach((l) => { | ||
l.push(s); | ||
}); | ||
} | ||
})(); | ||
resolve(nc); | ||
@@ -396,6 +387,8 @@ }) | ||
iter.iterClosed.then(() => { | ||
const idx = this.listeners.indexOf(iter); | ||
this.listeners.splice(idx, 1); | ||
const idx = this.protocol.listeners.indexOf(iter); | ||
if (idx > -1) { | ||
this.protocol.listeners.splice(idx, 1); | ||
} | ||
}); | ||
this.listeners.push(iter); | ||
this.protocol.listeners.push(iter); | ||
return iter; | ||
@@ -402,0 +395,0 @@ } |
import type { Transport } from "./transport"; | ||
import type { Deferred, Timeout } from "./util"; | ||
import type { Deferred, Delay, Timeout } from "./util"; | ||
import { DataBuffer } from "./databuffer"; | ||
@@ -118,2 +118,3 @@ import type { ServerImpl } from "./servers"; | ||
connectPromise: Promise<void> | null; | ||
dialDelay: Delay | null; | ||
raceTimer?: Timeout<void>; | ||
@@ -123,3 +124,2 @@ constructor(options: ConnectionOptions, publisher: Publisher); | ||
dispatchStatus(status: Status): void; | ||
status(): AsyncIterable<Status>; | ||
private prepare; | ||
@@ -154,4 +154,3 @@ disconnect(): void; | ||
sendSubscriptions(): void; | ||
private _close; | ||
close(): Promise<void>; | ||
close(err?: Error): Promise<void>; | ||
isClosed(): boolean; | ||
@@ -158,0 +157,0 @@ drain(): Promise<void>; |
@@ -327,2 +327,3 @@ "use strict"; | ||
connectPromise; | ||
dialDelay; | ||
raceTimer; | ||
@@ -353,2 +354,3 @@ constructor(options, publisher) { | ||
this.connectPromise = null; | ||
this.dialDelay = null; | ||
const servers = typeof options.servers === "string" | ||
@@ -383,7 +385,2 @@ ? [options.servers] | ||
} | ||
status() { | ||
const iter = new queued_iterator_1.QueuedIteratorImpl(); | ||
this.listeners.push(iter); | ||
return iter; | ||
} | ||
prepare() { | ||
@@ -451,7 +448,7 @@ if (this.transport) { | ||
.catch((err) => { | ||
this._close(err); | ||
this.close(err).catch(); | ||
}); | ||
} | ||
else { | ||
await this._close(err); | ||
await this.close(err).catch(); | ||
} | ||
@@ -583,3 +580,4 @@ } | ||
maxWait = Math.min(maxWait, srv.lastConnect + wait - now); | ||
await (0, util_1.delay)(maxWait); | ||
this.dialDelay = (0, util_1.delay)(maxWait); | ||
await this.dialDelay; | ||
} | ||
@@ -705,3 +703,3 @@ } | ||
// if we are dying here, this is likely some an authenticator blowing up | ||
this._close(err); | ||
this.close(err).catch(); | ||
} | ||
@@ -892,3 +890,3 @@ } | ||
} | ||
async _close(err) { | ||
async close(err) { | ||
if (this._closed) { | ||
@@ -905,13 +903,19 @@ return; | ||
this.subscriptions.close(); | ||
this.listeners.forEach((l) => { | ||
l.stop(); | ||
}); | ||
const proms = []; | ||
for (let i = 0; i < this.listeners.length; i++) { | ||
const qi = this.listeners[i]; | ||
if (qi) { | ||
qi.stop(); | ||
proms.push(qi.iterClosed); | ||
} | ||
} | ||
if (proms.length) { | ||
await Promise.all(proms); | ||
} | ||
this._closed = true; | ||
await this.transport.close(err); | ||
this.raceTimer?.cancel(); | ||
this.dialDelay?.cancel(); | ||
this.closed.resolve(err); | ||
} | ||
close() { | ||
return this._close(); | ||
} | ||
isClosed() { | ||
@@ -918,0 +922,0 @@ return this._closed; |
@@ -1,1 +0,1 @@ | ||
export declare const version = "3.0.0-40"; | ||
export declare const version = "3.0.0-41"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is generated - do not edit | ||
exports.version = "3.0.0-40"; | ||
exports.version = "3.0.0-41"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@nats-io/nats-core", | ||
"version": "3.0.0-40", | ||
"version": "3.0.0-41", | ||
"files": [ | ||
@@ -37,3 +37,3 @@ "lib/", | ||
"dependencies": { | ||
"@nats-io/nkeys": "1.2.0-7", | ||
"@nats-io/nkeys": "1.2.0-8", | ||
"@nats-io/nuid": "2.0.1-2" | ||
@@ -40,0 +40,0 @@ }, |
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
542732
8527
+ Added@nats-io/nkeys@1.2.0-8(transitive)
- Removed@nats-io/nkeys@1.2.0-7(transitive)
Updated@nats-io/nkeys@1.2.0-8