From bf8691fb0f884f0221c252407971e85c6e87f9d0 Mon Sep 17 00:00:00 2001
From: Gnought <1684105+gnought@users.noreply.github.com>
Date: Mon, 29 Jul 2019 14:58:07 +0800
Subject: [PATCH] MessageId should be unassigned in queue (#33)
* Added collaborators
* Add coverage & license check, format lint output
* Update .gitignore
* Added more badges
* MessageId should be unassigned in queue
outgoingEnqueue and outgoingEnqueueCombi functions should not store messageId. outgoingUpdate function will do. This PR requires https://github.com/mcollina/aedes-packet/pull/5
* Update .gitignore
* Update dependencies
* Add more badges in README.md
---
.gitignore | 5 ++++-
README.md | 16 ++++++++++++++--
abstract.js | 42 +++++++++++++++++++++++++++++-------------
package.json | 23 +++++++++++++++++++----
persistence.js | 3 ---
5 files changed, 66 insertions(+), 23 deletions(-)
diff --git a/.gitignore b/.gitignore
index 123ae94..d54dbe9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,8 +10,9 @@ pids
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
-# Coverage directory used by tools like istanbul
+# Coverage directory used by tools like nyc
coverage
+.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
@@ -25,3 +26,5 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
+
+package-lock.json
\ No newline at end of file
diff --git a/README.md b/README.md
index 4f50be7..0e6cc87 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,12 @@
-# aedes-persistence [![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg)](https://travis-ci.org/mcollina/aedes-persistence)
+# aedes-persistence
+[![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg?branch=master)](https://travis-ci.org/mcollina/aedes-persistence)
+[![Dependencies Status](https://david-dm.org/mcollina/aedes-persistence/status.svg)](https://david-dm.org/mcollina/aedes-persistence)
+[![devDependencies Status](https://david-dm.org/mcollina/aedes-persistence/dev-status.svg)](https://david-dm.org/mcollina/aedes-persistence?type=dev)
+
+[![Known Vulnerabilities](https://snyk.io/test/github/mcollina/aedes-persistence/badge.svg)](https://snyk.io/test/github/mcollina/aedes-persistence)
+[![Coverage Status](https://coveralls.io/repos/mcollina/aedes-persistence/badge.svg?branch=master&service=github)](https://coveralls.io/github/mcollina/aedes-persistence?branch=master)
+[![NPM version](https://img.shields.io/npm/v/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence)
+[![NPM downloads](https://img.shields.io/npm/dm/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence)
The spec for an [Aedes](http://npm.im/aedes) persistence, with abstract
tests and a fast in-memory implementation.
@@ -240,7 +248,7 @@ format:
### instance.getClientList(topic)
-Returns a stream which has all the clientIds subscribed to the
+Returns a stream which has all the clientIds subscribed to the
specified topic
@@ -281,6 +289,10 @@ abs({
})
```
+## Collaborators
+
+* [__Gnought__](https://github.com/gnought)
+
## License
MIT
diff --git a/abstract.js b/abstract.js
index 068d9e6..eed5739 100644
--- a/abstract.js
+++ b/abstract.js
@@ -770,8 +770,7 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
- brokerCounter: 42,
- messageId: 1
+ brokerCounter: 42
}
instance.outgoingEnqueue(sub, packet, function (err) {
@@ -779,7 +778,11 @@ function abstractPersistence (opts) {
var stream = instance.outgoingStream(client)
stream.pipe(concat(function (list) {
- t.deepEqual(list, [expected], 'must return the packet')
+ var packet = list[0]
+ t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
+ t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
+ delete packet.messageId
+ t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
})
@@ -821,19 +824,26 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
- brokerCounter: 42,
- messageId: 1
+ brokerCounter: 42
}
instance.outgoingEnqueueCombi(subs, packet, function (err) {
t.error(err)
var stream = instance.outgoingStream(client)
stream.pipe(concat(function (list) {
- t.deepEqual(list, [expected], 'must return the packet')
+ var packet = list[0]
+ t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
+ t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
+ delete packet.messageId
+ t.deepEqual(packet, expected, 'must return the packet')
var stream2 = instance.outgoingStream(client2)
stream2.pipe(concat(function (list) {
- t.deepEqual(list, [expected], 'must return the packet')
+ var packet = list[0]
+ t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
+ t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
+ delete packet.messageId
+ t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
}))
@@ -916,8 +926,7 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
- brokerCounter: 42,
- messageId: 1
+ brokerCounter: 42
}
instance.outgoingEnqueueCombi([sub], packet, function (err) {
@@ -925,7 +934,11 @@ function abstractPersistence (opts) {
var stream = instance.outgoingStream(client)
stream.pipe(concat(function (list) {
- t.deepEqual(list, [expected], 'must return the packet')
+ var packet = list[0]
+ t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
+ t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
+ delete packet.messageId
+ t.deepEqual(packet, expected, 'must return the packet')
instance.destroy(t.end.bind(t))
}))
})
@@ -959,8 +972,7 @@ function abstractPersistence (opts) {
qos: 1,
retain: false,
brokerId: instance.broker.id,
- brokerCounter: 42,
- messageId: 4242
+ brokerCounter: 42
}
instance.outgoingEnqueueCombi([sub], packet, function (err) {
@@ -968,7 +980,11 @@ function abstractPersistence (opts) {
var stream = instance.outgoingStream(client)
stream.pipe(concat(function (list) {
- t.deepEqual(list, [expected], 'must return the packet')
+ var packet = list[0]
+ t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId'))
+ t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue')
+ delete packet.messageId
+ t.deepEqual(packet, expected, 'must return the packet')
var stream = instance.outgoingStream(client)
diff --git a/package.json b/package.json
index 630b133..7b7377c 100644
--- a/package.json
+++ b/package.json
@@ -4,9 +4,15 @@
"description": "The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.",
"main": "persistence.js",
"scripts": {
- "test": "standard && tape test.js | faucet"
+ "lint": "standard --verbose | snazzy",
+ "test": "tape test.js | faucet",
+ "coverage": "nyc --reporter=lcov tape test.js",
+ "license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'"
},
- "pre-commit": "test",
+ "pre-commit": [
+ "lint",
+ "test"
+ ],
"repository": {
"type": "git",
"url": "git+https://github.com/mcollina/aedes-persistence.git"
@@ -18,6 +24,12 @@
"aedes"
],
"author": "Matteo Collina ",
+ "contributors": [
+ {
+ "name": "Gnought",
+ "url": "https://github.com/gnought"
+ }
+ ],
"license": "MIT",
"bugs": {
"url": "https://github.com/mcollina/aedes-persistence/issues"
@@ -26,15 +38,18 @@
"devDependencies": {
"concat-stream": "^2.0.0",
"faucet": "0.0.1",
+ "license-checker": "^25.0.1",
"mqemitter": "^3.0.0",
+ "nyc": "^14.1.1",
"pre-commit": "^1.2.2",
"pump": "^3.0.0",
- "standard": "^13.0.2",
+ "snazzy": "^8.0.0",
+ "standard": "^13.1.0",
"tape": "^4.11.0",
"through2": "^3.0.1"
},
"dependencies": {
- "aedes-packet": "^2.0.0",
+ "aedes-packet": "^2.1.0",
"from2": "^2.3.0",
"qlobber": "^3.1.0"
}
diff --git a/persistence.js b/persistence.js
index 805378a..b239691 100644
--- a/persistence.js
+++ b/persistence.js
@@ -185,9 +185,6 @@ function _outgoingEnqueue (sub, packet) {
this._outgoing[id] = queue
var p = new Packet(packet)
- if (packet.messageId) {
- p.messageId = packet.messageId
- }
queue[queue.length] = p
}