
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
aedes-persistence
Advanced tools
The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.
The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.
To install aedes-persistence, simply use npm:
npm install aedes-persistence --save
persistence()
instance.storeRetained()
instance.createRetainedStream()
instance.createRetainedStreamCombi()
instance.addSubscriptions()
instance.removeSubscriptions()
instance.subscriptionsByClient()
instance.countOffline()
instance.subscriptionsByTopic()
instance.cleanSubscriptions()
instance.outgoingEnqueue()
instance.outgoingEnqueueCombi()
instance.outgoingUpdate()
instance.outgoingClearMessageId()
instance.outgoingStream()
instance.incomingStorePacket()
instance.incomingGetPacket()
instance.incomingDelPacket()
instance.putWill()
instance.getWill()
instance.delWill()
instance.streamWill()
instance.getClientList()
instance.destroy()
Creates a new instance of a persistence, that is already ready to operate. The default implementation is in-memory only.
Store a retained message, calls the callback when it was saved.
Return a stream that will load all retained messages matching the given pattern (according to the MQTT spec) asynchronously. Deprecated.
Return a stream that will load all retained messages matching given patterns (according to the MQTT spec) asynchronously.
Add the given offline subscriptions for the given
Client. The client must
have connected with clean: false
, as this is not checked here.
This is called when a client issue a SUBSCRIBE packet.
subscriptions
is in the same format of the subscribe
property in the
SUBSCRIBE packet:
[{
topic: 'hello/world',
qos: 1,
}, {
topic: 'hello/#',
qos: 2,
}]
The inverse of addSubscriptions
but subscriptions is an array of topic names.
Returns all the offline subscriptions for the given client. Called when
a client with clean: false
connects to restore its subscriptions.
subscriptions
is in the same format of the subscribe
property in the
SUBSCRIBE packet:
[{
topic: 'hello/world',
qos: 1,
}, {
topic: 'hello/#',
qos: 2,
}]
Returns the number of offline subscriptions and the number of offline clients.
Returns all the offline subscriptions matching the given pattern. Called when
a PUBLISH with qos: 1
or qos: 2
is received.
The subscriptions are in the format:
{
clientId: client.id,
topic: sub.topic,
qos: sub.qos
}
Removes all offline subscriptions for a given client.
Enqueue a potentially offline delivery. subscription
is one of the
objects returned by subscriptionsByTopic
. Deprecated.
Enqueue a potentially offline delivery. subscriptions
is the whole subscriptions
objects returned by subscriptionsByTopic
.
Called before a (potentially) offline packet is delivered, the caller
should update the packet.messageId
before updating.
Removes a packet with the given messageId
(passing a PUBACK is ok)
from the persistence. Passes back original packet to the callback.
Return a stream that will load all offline messages for the given client asynchronously.
Store an incoming packet for the given client. Used for QoS 2.
Retrieve an incoming packet with the same messageId
for the given client. Used for QoS 2.
Deletes incoming packet with the same messageId
for the given client. Used for QoS 2.
Stores the will of a client. Used to support multi-broker environments and to not lose wills in case of a crash.
Retrieves the will of a client. Used to support multi-broker environments and to not lose wills in case of a crash.
Removes the will of a client. Used to support multi-broker environments and to not lose wills in case of a crash.
Streams all the wills for the given brokers. The brokers are in the format:
{
mybroker: {
brokerId: 'mybroker'
}
}
Returns a stream which has all the clientIds subscribed to the specified topic
Destroy current persistence. Use callback cb(err)
to catch errors if any
A persistence needs to pass all tests defined in ./abstract.js. You can import and use that test suite in the following manner:
var test = require('tape').test
var myperst = require('./')
var abs = require('aedes-persistence/abstract')
abs({
test: test,
persistence: myperst
})
If you require some async stuff before returning, a callback is also supported:
var test = require('tape').test
var myperst = require('./')
var abs = require('aedes-persistence/abstract')
var clean = require('./clean') // invented module
abs({
test: test,
buildEmitter: require('mymqemitter'), // optional
persistence: function build (cb) {
clean(function (err) {
cb(err, myperst())
})
}
})
MIT
FAQs
The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.
The npm package aedes-persistence receives a total of 67,560 weekly downloads. As such, aedes-persistence popularity was classified as popular.
We found that aedes-persistence demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.