node-nats-streaming
- Version 0.3.2
- Published
- 253 kB
- 3 dependencies
- Apache-2.0 license
Install
npm i node-nats-streaming
yarn add node-nats-streaming
pnpm add node-nats-streaming
Overview
Node.js client for NATS Streaming, a lightweight, high-performance cloud native messaging system
Index
Variables
Functions
Classes
Interfaces
Enums
Variables
variable version
const version: string;
Functions
function connect
connect: (clusterID: string, clientID: string, opts?: StanOptions) => Stan;
Connect to a nats-server and return the client. Argument can be a url, or an object with a 'url' property and additional options.
Classes
class Message
class Message {}
method ack
ack: () => void;
Acks the message, note this method shouldn't be called unless the manualAcks option was set on the subscription.
method getCrc32
getCrc32: () => number;
Returns an optional IEEE CRC32 checksum
method getData
getData: () => String | Buffer;
Returns the data associated with the message payload. If the stanEncoding is not set to 'binary', a string is returned.
method getRawData
getRawData: () => Buffer;
Returns a Buffer with the raw message payload
method getSequence
getSequence: () => number;
Returns the sequence number of the message in the stream.
method getSubject
getSubject: () => string;
Returns the subject associated with this Message
method getTimestamp
getTimestamp: () => Date;
Returns a Date object representing the timestamp of the message. This is an approximation of the timestamp.
method getTimestampRaw
getTimestampRaw: () => number;
Returns the raw timestamp set on the message. This number is not a valid time in JavaScript.
method isRedelivered
isRedelivered: () => boolean;
Returns a boolean indicating if the message is being redelivered
class Stan
class Stan extends events.EventEmitter {}
method close
close: () => void;
Close the connection to the server.
method publish
publish: ( subject: string, data?: Uint8Array | string | Buffer, callback?: AckHandlerCallback) => string;
Publishes a message to the streaming server with the specified subject and data.
Parameter subject
Parameter data
Parameter callback
Returns
guid generated for the published message
method subscribe
subscribe: { (subject: string, opts?: SubscriptionOptions): Subscription; (subject: string, qGroup: string, opts?: SubscriptionOptions): Subscription;};
Subscribes to a given subject as an optional member of a queue group.
Parameter subject
Parameter qGroup
Parameter opts
method subscriptionOptions
subscriptionOptions: () => SubscriptionOptions;
Returns a SubscriptionOptions initialized to defaults
class Subscription
class Subscription extends events.EventEmitter {}
method close
close: () => void;
Close removes the subscriber from the server, but unlike the Subscription#unsubscribe(), the durable interest is not removed. If the client has connected to a server for which this feature is not available, Subscription#Close() will emit a Subscription#error(NO_SERVER_SUPPORT) error. Note that this affects durable clients only. If called on a non-durable subscriber, this is equivalent to Subscription#close()
method isClosed
isClosed: () => boolean;
Returns true if the subscription has been closed or unsubscribed from.
method unsubscribe
unsubscribe: () => void;
Unregisters the subscription from the streaming server.
Interfaces
interface AckHandlerCallback
interface AckHandlerCallback {}
Callback informs the client that the message was processed by the server
Parameter err
undefined if there is no error processing the message
Parameter guid
the guid correlating the message with the callback invocation.
call signature
(err: Error | undefined, guid: string): void;
interface ClientOpts
interface ClientOpts {}
property encoding
encoding?: BufferEncoding;
property maxPingOut
maxPingOut?: number;
property maxReconnectAttempts
maxReconnectAttempts?: number;
property name
name?: string;
property nkey
nkey?: string;
property nonceSigner
nonceSigner?: Function;
property noRandomize
noRandomize?: boolean;
property pass
pass?: string;
property pedantic
pedantic?: boolean;
property pingInterval
pingInterval?: number;
property reconnect
reconnect?: boolean;
property reconnectTimeWait
reconnectTimeWait?: number;
property servers
servers?: Array<string>;
property tls
tls?: boolean | tls.TlsOptions;
property token
token?: string;
property tokenHandler
tokenHandler?: Function;
property url
url?: string;
property useOldRequestStyle
useOldRequestStyle?: boolean;
property user
user?: string;
property userCreds
userCreds?: string;
property userJWT
userJWT?: string | Function;
property verbose
verbose?: boolean;
property waitOnFirstConnect
waitOnFirstConnect?: boolean;
property yieldTime
yieldTime?: number;
interface StanOptions
interface StanOptions extends ClientOpts {}
property ackTimeout
ackTimeout?: number;
property connectTimeout
connectTimeout?: number;
property discoverPrefix
discoverPrefix?: string;
property maxPubAcksInflight
maxPubAcksInflight?: number;
property nc
nc?: nats.Client;
property stanEncoding
stanEncoding?: string;
property stanMaxPingOut
stanMaxPingOut?: number;
property stanPingInterval
stanPingInterval?: number;
property url
url?: string;
interface SubscriptionOptions
interface SubscriptionOptions {}
property ackWait
ackWait?: number;
property durableName
durableName?: string;
property manualAcks
manualAcks?: boolean;
property maxInFlight
maxInFlight?: number;
property startPosition
startPosition: StartPosition;
property startSequence
startSequence?: number;
property startTime
startTime?: number;
method setAckWait
setAckWait: (millis: number) => SubscriptionOptions;
Sets the number of milliseconds before a message is considered unacknowledged by the streaming server.
method setDeliverAllAvailable
setDeliverAllAvailable: () => SubscriptionOptions;
Configures the subscription to replay from first available message.
method setDurableName
setDurableName: (durableName: string) => SubscriptionOptions;
Sets a durable subscription name that the client can specify for the subscription. This enables the subscriber to close the connection without canceling the subscription and resume the subscription with same durable name. Note the server will resume the subscription with messages that have not been acknowledged.
Parameter durableName
method setManualAckMode
setManualAckMode: (tf: boolean) => SubscriptionOptions;
Configures the subscription to require manual acknowledgement of messages using Message#acknowledge.
Parameter tf
true if manual acknowlegement is required.
method setMaxInFlight
setMaxInFlight: (n: number) => SubscriptionOptions;
Sets the maximun number of unacknowledged messages that the streaming server will allow before it sends a message.
Parameter n
method setStartAt
setStartAt: (startPosition: StartPosition) => SubscriptionOptions;
Configures the subscription start mode. Typically you would invoke this message with StartPostion#FIRST, StartPosition#NEW_ONLY or StartPosition#LAST_RECEIVED. For all other uses (SubscriptionOptions#setStartSequence, SubscriptionOptions#setStartTime, SubscriptionOptions#setStartAtTimeDelta, or SubscriptionOptions#setStartWithLastReceived), the method will configure the startup value and position.
Parameter startPosition
method setStartAtSequence
setStartAtSequence: (sequence: number) => SubscriptionOptions;
Configures the subscription to start with the message having the specified sequence number.
Parameter sequence
method setStartAtTimeDelta
setStartAtTimeDelta: (millis: number) => SubscriptionOptions;
Configures the subscription to replay messages sent milliseconds ago.
Parameter millis
the number of milliseconds ago to use as the start time
method setStartTime
setStartTime: (date: Date) => SubscriptionOptions;
Configures the subscription to start with messages sent at the specified date.
Parameter date
method setStartWithLastReceived
setStartWithLastReceived: () => SubscriptionOptions;
Configures the subscription to replay with the last received message.
Enums
enum StartPosition
enum StartPosition { NEW_ONLY = 0, LAST_RECEIVED, TIME_DELTA_START, SEQUENCE_START, FIRST,}
member FIRST
FIRST
member LAST_RECEIVED
LAST_RECEIVED
member NEW_ONLY
NEW_ONLY = 0
member SEQUENCE_START
SEQUENCE_START
member TIME_DELTA_START
TIME_DELTA_START
Package Files (1)
Dependencies (3)
Dev Dependencies (11)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/node-nats-streaming
.
- Markdown[](https://www.jsdocs.io/package/node-nats-streaming)
- HTML<a href="https://www.jsdocs.io/package/node-nats-streaming"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1132 ms. - Missing or incorrect documentation? Open an issue for this package.