nats
Version:
Node.js client for NATS, a lightweight, high-performance cloud native messaging system
224 lines • 8.48 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepublishHeaders = exports.DirectMsgHeaders = exports.JsHeaders = exports.ReplayPolicy = exports.AckPolicy = exports.DeliverPolicy = exports.StorageType = exports.DiscardPolicy = exports.RetentionPolicy = exports.AdvisoryKind = exports.RequestStrategy = exports.DEFAULT_MAX_PING_OUT = exports.DEFAULT_PING_INTERVAL = exports.DEFAULT_JITTER_TLS = exports.DEFAULT_JITTER = exports.DEFAULT_MAX_RECONNECT_ATTEMPTS = exports.DEFAULT_RECONNECT_TIME_WAIT = exports.DEFAULT_HOST = exports.DEFAULT_PORT = exports.DebugEvents = exports.Events = exports.Empty = exports.NatsError = void 0;
var error_1 = require("./error");
Object.defineProperty(exports, "NatsError", { enumerable: true, get: function () { return error_1.NatsError; } });
exports.Empty = new Uint8Array(0);
/**
* 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 || (exports.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 = exports.DebugEvents || (exports.DebugEvents = {}));
exports.DEFAULT_PORT = 4222;
exports.DEFAULT_HOST = "127.0.0.1";
// DISCONNECT Parameters, 2 sec wait, 10 tries
exports.DEFAULT_RECONNECT_TIME_WAIT = 2 * 1000;
exports.DEFAULT_MAX_RECONNECT_ATTEMPTS = 10;
exports.DEFAULT_JITTER = 100;
exports.DEFAULT_JITTER_TLS = 1000;
// Ping interval
exports.DEFAULT_PING_INTERVAL = 2 * 60 * 1000; // 2 minutes
exports.DEFAULT_MAX_PING_OUT = 2;
var RequestStrategy;
(function (RequestStrategy) {
RequestStrategy["Timer"] = "timer";
RequestStrategy["Count"] = "count";
RequestStrategy["JitterTimer"] = "jitterTimer";
RequestStrategy["SentinelMsg"] = "sentinelMsg";
})(RequestStrategy = exports.RequestStrategy || (exports.RequestStrategy = {}));
/**
* The different kinds of Advisories
*/
var AdvisoryKind;
(function (AdvisoryKind) {
AdvisoryKind["API"] = "api_audit";
AdvisoryKind["StreamAction"] = "stream_action";
AdvisoryKind["ConsumerAction"] = "consumer_action";
AdvisoryKind["SnapshotCreate"] = "snapshot_create";
AdvisoryKind["SnapshotComplete"] = "snapshot_complete";
AdvisoryKind["RestoreCreate"] = "restore_create";
AdvisoryKind["RestoreComplete"] = "restore_complete";
AdvisoryKind["MaxDeliver"] = "max_deliver";
AdvisoryKind["Terminated"] = "terminated";
AdvisoryKind["Ack"] = "consumer_ack";
AdvisoryKind["StreamLeaderElected"] = "stream_leader_elected";
AdvisoryKind["StreamQuorumLost"] = "stream_quorum_lost";
AdvisoryKind["ConsumerLeaderElected"] = "consumer_leader_elected";
AdvisoryKind["ConsumerQuorumLost"] = "consumer_quorum_lost";
})(AdvisoryKind = exports.AdvisoryKind || (exports.AdvisoryKind = {}));
var RetentionPolicy;
(function (RetentionPolicy) {
/**
* Retain messages until the limits are reached, then trigger the discard policy.
*/
RetentionPolicy["Limits"] = "limits";
/**
* Retain messages while there is consumer interest on the particular subject.
*/
RetentionPolicy["Interest"] = "interest";
/**
* Retain messages until acknowledged
*/
RetentionPolicy["Workqueue"] = "workqueue";
})(RetentionPolicy = exports.RetentionPolicy || (exports.RetentionPolicy = {}));
var DiscardPolicy;
(function (DiscardPolicy) {
/**
* Discard old messages to make room for the new ones
*/
DiscardPolicy["Old"] = "old";
/**
* Discard the new messages
*/
DiscardPolicy["New"] = "new";
})(DiscardPolicy = exports.DiscardPolicy || (exports.DiscardPolicy = {}));
var StorageType;
(function (StorageType) {
/**
* Store persistently on files
*/
StorageType["File"] = "file";
/**
* Store in server memory - doesn't survive server restarts
*/
StorageType["Memory"] = "memory";
})(StorageType = exports.StorageType || (exports.StorageType = {}));
var DeliverPolicy;
(function (DeliverPolicy) {
/**
* Deliver all messages
*/
DeliverPolicy["All"] = "all";
/**
* Deliver starting with the last message
*/
DeliverPolicy["Last"] = "last";
/**
* Deliver starting with new messages
*/
DeliverPolicy["New"] = "new";
/**
* Deliver starting with the specified sequence
*/
DeliverPolicy["StartSequence"] = "by_start_sequence";
/**
* Deliver starting with the specified time
*/
DeliverPolicy["StartTime"] = "by_start_time";
/**
* Deliver starting with the last messages for every subject
*/
DeliverPolicy["LastPerSubject"] = "last_per_subject";
})(DeliverPolicy = exports.DeliverPolicy || (exports.DeliverPolicy = {}));
var AckPolicy;
(function (AckPolicy) {
/**
* Messages don't need to be Ack'ed.
*/
AckPolicy["None"] = "none";
/**
* Ack, acknowledges all messages with a lower sequence
*/
AckPolicy["All"] = "all";
/**
* All sequences must be explicitly acknowledged
*/
AckPolicy["Explicit"] = "explicit";
/**
* @ignore
*/
AckPolicy["NotSet"] = "";
})(AckPolicy = exports.AckPolicy || (exports.AckPolicy = {}));
var ReplayPolicy;
(function (ReplayPolicy) {
/**
* Replays messages as fast as possible
*/
ReplayPolicy["Instant"] = "instant";
/**
* Replays messages following the original delay between messages
*/
ReplayPolicy["Original"] = "original";
})(ReplayPolicy = exports.ReplayPolicy || (exports.ReplayPolicy = {}));
var JsHeaders;
(function (JsHeaders) {
/**
* Set if message is from a stream source - format is `stream seq`
*/
JsHeaders["StreamSourceHdr"] = "Nats-Stream-Source";
/**
* Set for heartbeat messages
*/
JsHeaders["LastConsumerSeqHdr"] = "Nats-Last-Consumer";
/**
* Set for heartbeat messages
*/
JsHeaders["LastStreamSeqHdr"] = "Nats-Last-Stream";
/**
* Set for heartbeat messages if the consumer is stalled
*/
JsHeaders["ConsumerStalledHdr"] = "Nats-Consumer-Stalled";
/**
* Set for headers_only consumers indicates the number of bytes in the payload
*/
JsHeaders["MessageSizeHdr"] = "Nats-Msg-Size";
// rollup header
JsHeaders["RollupHdr"] = "Nats-Rollup";
// value for rollup header when rolling up a subject
JsHeaders["RollupValueSubject"] = "sub";
// value for rollup header when rolling up all subjects
JsHeaders["RollupValueAll"] = "all";
})(JsHeaders = exports.JsHeaders || (exports.JsHeaders = {}));
var DirectMsgHeaders;
(function (DirectMsgHeaders) {
DirectMsgHeaders["Stream"] = "Nats-Stream";
DirectMsgHeaders["Sequence"] = "Nats-Sequence";
DirectMsgHeaders["TimeStamp"] = "Nats-Time-Stamp";
DirectMsgHeaders["Subject"] = "Nats-Subject";
})(DirectMsgHeaders = exports.DirectMsgHeaders || (exports.DirectMsgHeaders = {}));
var RepublishHeaders;
(function (RepublishHeaders) {
/**
* The source stream of the message
*/
RepublishHeaders["Stream"] = "Nats-Stream";
/**
* The original subject of the message
*/
RepublishHeaders["Subject"] = "Nats-Subject";
/**
* The sequence of the republished message
*/
RepublishHeaders["Sequence"] = "Nats-Sequence";
/**
* The stream sequence id of the last message ingested to the same original subject (or 0 if none or deleted)
*/
RepublishHeaders["LastSequence"] = "Nats-Last-Sequence";
/**
* The size in bytes of the message's body - Only if {@link Republish#headers_only} is set.
*/
RepublishHeaders["Size"] = "Nats-Msg-Size";
})(RepublishHeaders = exports.RepublishHeaders || (exports.RepublishHeaders = {}));
//# sourceMappingURL=types.js.map