node-nats-streaming
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -18,2 +18,3 @@ /* | ||
import nats = require('nats'); | ||
import * as tls from 'tls'; | ||
// import proto = require('./lib/pb'); | ||
@@ -32,3 +33,3 @@ | ||
export interface StanOptions { | ||
export interface StanOptions extends ClientOpts { | ||
url?: string, | ||
@@ -40,6 +41,31 @@ connectTimeout?: number, | ||
stanEncoding?: string, | ||
stanMaxPingOut?: number, | ||
stanPingInterval?: number, | ||
nc?: nats.Client | ||
} | ||
// these are standard node-nats options, some are omitted until | ||
// nats-streaming-server supports them. Others like encoding | ||
// must always be set to binary. | ||
export interface ClientOpts { | ||
url?: string, | ||
user?: string, | ||
pass?: string, | ||
verbose?: boolean, | ||
pedantic?: boolean, | ||
reconnect?: boolean, | ||
maxReconnectAttempts?: number, | ||
reconnectTimeWait?: number, | ||
servers?: Array<string>, | ||
noRandomize?: boolean, | ||
tls?: boolean | tls.TlsOptions, | ||
name?: string, | ||
yieldTime?: number, | ||
waitOnFirstConnect?: boolean, | ||
token?: string, | ||
pingInterval?: number, | ||
maxPingOut?: number, | ||
} | ||
declare class Message { | ||
@@ -121,3 +147,3 @@ /** | ||
*/ | ||
interface AckHandlerCallback { (err: Error, guid: string): void; } | ||
interface AckHandlerCallback { (err: Error | undefined, guid: string): void; } | ||
@@ -247,2 +273,2 @@ | ||
setDurableName(durableName: string): SubscriptionOptions; | ||
} | ||
} |
@@ -35,3 +35,3 @@ /* | ||
*/ | ||
var VERSION = '0.1.0', | ||
var VERSION = '0.2.0', | ||
DEFAULT_PORT = 4222, | ||
@@ -136,4 +136,4 @@ DEFAULT_PRE = 'nats://localhost:', | ||
stanEncoding: 'utf8', | ||
pingInterval: DEFAULT_PING_INTERVAL, | ||
pingMaxOut: DEFAULT_PING_MAXOUT, | ||
stanPingInterval: DEFAULT_PING_INTERVAL, | ||
stanMaxPingOut: DEFAULT_PING_MAXOUT, | ||
maxReconnectAttempts: -1 | ||
@@ -160,4 +160,4 @@ }; | ||
this.assignOption(opts, 'stanEncoding'); | ||
this.assignOption(opts, 'pingInterval'); | ||
this.assignOption(opts, 'pingMaxOut'); | ||
this.assignOption(opts, 'stanPingInterval'); | ||
this.assignOption(opts, 'stanMaxPingOut'); | ||
@@ -190,2 +190,6 @@ // node-nats does takes a bunch of other options | ||
this.assignOption(opts, 'waitOnFirstConnect'); | ||
this.assignOption(opts, 'preserveBuffers'); | ||
this.assignOption(opts, 'pingInterval'); | ||
this.assignOption(opts, 'maxPingOut'); | ||
this.assignOption(opts, 'useOldRequestStyle'); | ||
} | ||
@@ -321,4 +325,4 @@ }; | ||
req.setConnId(that.connId); | ||
req.setPingInterval(Math.ceil(that.options.pingInterval / 1000)); | ||
req.setPingMaxOut(that.options.pingMaxOut); | ||
req.setPingInterval(Math.ceil(that.options.stanPingInterval / 1000)); | ||
req.setPingMaxOut(that.options.stanMaxPingOut); | ||
@@ -351,4 +355,4 @@ | ||
that.pingRequests = cr.getPingRequests(); | ||
that.pingInterval = cr.getPingInterval() * 1000; | ||
that.pingMaxOut = cr.getPingMaxOut(); | ||
that.stanPingInterval = cr.getPingInterval() * 1000; | ||
that.stanMaxPingOut = cr.getPingMaxOut(); | ||
@@ -362,3 +366,3 @@ var ping = new proto.Ping(); | ||
that.pingOut++; | ||
if (that.pingOut > that.pingMaxOut) { | ||
if (that.pingOut > that.stanMaxPingOut) { | ||
that.closeWithError('connection_lost', new Error(MAX_PINGS_EXCEEDED)); | ||
@@ -368,4 +372,4 @@ return; | ||
that.nc.publish(that.pingRequests, that.pingBytes, that.pingInbox); | ||
that.pingTimer = setTimeout(pingFun, that.pingInterval); | ||
}, that.pingInterval); | ||
that.pingTimer = setTimeout(pingFun, that.stanPingInterval); | ||
}, that.stanPingInterval); | ||
} | ||
@@ -372,0 +376,0 @@ } |
{ | ||
"name": "node-nats-streaming", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Node.js client for NATS Streaming, a lightweight, high-performance cloud native messaging system", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -230,4 +230,4 @@ # NATS Streaming - Node.js Client | ||
sc.connect('test-cluster', 'test', { | ||
maxPingOut: 3, | ||
pingInterval: 1000 | ||
stanMaxPingOut: 3, | ||
stanPingInterval: 1000 | ||
}); | ||
@@ -234,0 +234,0 @@ |
161440
3951