node-nats-streaming
Advanced tools
+4
-7
@@ -24,3 +24,3 @@ /*! | ||
| */ | ||
| var VERSION = '0.0.8', | ||
| var VERSION = '0.0.10', | ||
| DEFAULT_PORT = 4222, | ||
@@ -256,3 +256,2 @@ DEFAULT_PRE = 'nats://localhost:', | ||
| that.nc.request(discoverSubject, new Buffer(req.serializeBinary()), {max:1}, function(msg) { | ||
| //noinspection JSUnresolvedVariable | ||
| var cr = proto.ConnectResponse.deserializeBinary(new Buffer(msg, 'binary').toByteArray()); | ||
@@ -476,3 +475,2 @@ that.pubPrefix = cr.getPubPrefix(); | ||
| retVal.inboxSub = this.nc.subscribe(retVal.inbox, this.processMsg()); | ||
| //noinspection JSUnresolvedFunction | ||
| var sr = new proto.SubscriptionRequest(); | ||
@@ -490,3 +488,3 @@ sr.setClientId(this.clientID); | ||
| case proto.StartPosition.TIME_DELTA_START: | ||
| sr.setStartAtTimeDelta(retVal.opts.startTime); | ||
| sr.setStartTimeDelta(retVal.opts.startTime); | ||
| break; | ||
@@ -811,3 +809,3 @@ case proto.StartPosition.SEQUENCE_START: | ||
| // server expects values in ns | ||
| this.startTime = date.getTime() * 1000000; | ||
| this.startTime = (Date.now() - date.valueOf()) * 1000000; | ||
| return this; | ||
@@ -823,5 +821,4 @@ }; | ||
| //noinspection JSUnresolvedFunction | ||
| var now = new Date().getTime(); | ||
| // server expects values in ns | ||
| this.startTime = (now - millis) * 1000000; | ||
| this.startTime = millis * 1000000; | ||
| return this; | ||
@@ -828,0 +825,0 @@ }; |
+1
-1
| { | ||
| "name": "node-nats-streaming", | ||
| "version": "0.0.8", | ||
| "version": "0.0.10", | ||
| "description": "Node.js client for NATS Streaming, a lightweight, high-performance cloud native messaging system", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+84
-0
@@ -150,2 +150,3 @@ /* jshint node: true */ | ||
| it('should include the correct reply in the callback', function (done) { | ||
@@ -443,2 +444,85 @@ var stan = STAN.connect(cluster, nuid.next(), PORT); | ||
| it('subscribe after 500ms on last received', function (done) { | ||
| this.timeout(5000); | ||
| var stan = STAN.connect(cluster, nuid.next(), PORT); | ||
| var subj = nuid.next(); | ||
| var count = 0; | ||
| function subscribe() { | ||
| var gotFirst = false; | ||
| var opts = stan.subscriptionOptions(); | ||
| opts.setStartAtTimeDelta(1000); | ||
| var sub = stan.subscribe(subj, opts); | ||
| sub.on('message', function (msg) { | ||
| if (!gotFirst) { | ||
| gotFirst = true; | ||
| should(msg.getData()).equal('fourth', 'message was not the one expected'); | ||
| done(); | ||
| } | ||
| }); | ||
| } | ||
| var waitForSix = function () { | ||
| count++; | ||
| if (count === 6) { | ||
| process.nextTick(subscribe); | ||
| } | ||
| }; | ||
| stan.on('connect', function () { | ||
| stan.publishAsync(subj, 'first', waitForSix); | ||
| stan.publishAsync(subj, 'second', waitForSix); | ||
| stan.publishAsync(subj, 'third', waitForSix); | ||
| setTimeout(function() { | ||
| stan.publishAsync(subj, 'fourth', waitForSix); | ||
| stan.publishAsync(subj, 'fifth', waitForSix); | ||
| stan.publishAsync(subj, 'sixth', waitForSix); | ||
| }, 1500); | ||
| }); | ||
| }); | ||
| it('subscribe after a specific time on last received', function (done) { | ||
| this.timeout(6000); | ||
| var stan = STAN.connect(cluster, nuid.next(), PORT); | ||
| var subj = nuid.next(); | ||
| var count = 0; | ||
| function subscribe() { | ||
| var gotFirst = false; | ||
| var opts = stan.subscriptionOptions(); | ||
| opts.setStartTime(new Date(Date.now() - 1000)); | ||
| var sub = stan.subscribe(subj, opts); | ||
| sub.on('message', function (msg) { | ||
| if (!gotFirst) { | ||
| gotFirst = true; | ||
| // node will be spurious since we are in a single thread | ||
| var ok = msg.getData() === 'fourth' || msg.getData() === 'fifth' || msg.getData() === 'sixth'; | ||
| should(ok).equal(true, 'message was not the one expected'); | ||
| done(); | ||
| } | ||
| }); | ||
| } | ||
| var waitForSix = function () { | ||
| count++; | ||
| if (count === 6) { | ||
| process.nextTick(subscribe); | ||
| } | ||
| }; | ||
| stan.on('connect', function () { | ||
| stan.publishAsync(subj, 'first', waitForSix); | ||
| stan.publishAsync(subj, 'second', waitForSix); | ||
| stan.publishAsync(subj, 'third', waitForSix); | ||
| setTimeout(function() { | ||
| stan.publishAsync(subj, 'fourth', waitForSix); | ||
| stan.publishAsync(subj, 'fifth', waitForSix); | ||
| stan.publishAsync(subj, 'sixth', waitForSix); | ||
| }, 1500); | ||
| }); | ||
| }); | ||
| it('subscribe starting on new', function (done) { | ||
@@ -445,0 +529,0 @@ var stan = STAN.connect(cluster, nuid.next(), PORT); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
163732
1.47%4692
1.49%