Skip to content

Commit

Permalink
chore: drop bulk-write-stream (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought authored Apr 19, 2022
1 parent 0c2b068 commit 0786082
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions aedes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ const util = require('util')
const parallel = require('fastparallel')
const series = require('fastseries')
const { v4: uuidv4 } = require('uuid')
const bulk = require('bulk-write-stream')
const reusify = require('reusify')
const { pipeline } = require('stream')
const Packet = require('aedes-packet')
const memory = require('aedes-persistence')
const mqemitter = require('mqemitter')
const Client = require('./lib/client')
const { $SYS_PREFIX } = require('./lib/utils')
const { $SYS_PREFIX, bulk } = require('./lib/utils')

module.exports = Aedes.Server = Aedes

Expand Down Expand Up @@ -102,7 +101,7 @@ function Aedes (opts) {

pipeline(
that.persistence.streamWill(that.brokers),
bulk.obj(receiveWills),
bulk(receiveWills),
function done (err) {
if (err) {
that.emit('error', err)
Expand Down
12 changes: 11 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { Transform } = require('stream')
const { Transform, Writable } = require('stream')

function validateTopic (topic, message) {
const end = topic.length - 1
Expand Down Expand Up @@ -37,8 +37,18 @@ function through (transform) {
})
}

function bulk (fn) {
return new Writable({
objectMode: true,
writev: function (chunks, cb) {
fn(chunks.map(chunk => chunk.chunk), cb)
}
})
}

module.exports = {
validateTopic,
through,
bulk,
$SYS_PREFIX: '$SYS/'
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"dependencies": {
"aedes-packet": "^2.3.1",
"aedes-persistence": "^8.1.3",
"bulk-write-stream": "^2.0.1",
"end-of-stream": "^1.4.4",
"fastfall": "^1.5.1",
"fastparallel": "^2.4.1",
Expand Down

0 comments on commit 0786082

Please sign in to comment.