0.2.0 • Published 4 years ago
aedes-persistence-cassandra v0.2.0
aedes-persistence-cassandra
Aedes persistence, backed by Cassandra.
See aedes-persistence for the full API, and Aedes for usage.
NOTE: preliminary version, WIP.
Install
npm install aedes aedes-persistence-cassandra --saveor
yarn add mqemitter-kafka aedes-persistence-cassandraTarget keyspace must be initialized with aedes.cql script.
API
AedesPersistenceCassandra(opts)
Creates a new instance of aedes-persistence-cassandra.
Options
ttl: Used to set a ttl (time to live) to documents stored in collectionspackets: Could be an integer value that specify the ttl in seconds of all packets collections or an Object that specifies for each collection its ttl in seconds. Packets collections are:incoming,outgoing,retained,will.susbscriptions: Set a ttl (in seconds)
cassandra: Extra options to pass to Cassandra driver (see cassandra-driver) (alternative toclient)client: Existingcassandra-driverclient instance (alternative tocassandra)
If neither cassandra or client option are supplied, connection to localhost:9042 will be attempted with local datacenter datacenter1 and keyspace aedes.
Supplying an external client it's recommended.
Examples
const AedesPersistenceCassandra = require("aedes-persistence-cassandra");
AedesPersistenceCassandra({
cassandra: {
contactPoints: ["localhost:9042"],
localDataCenter: "datacenter1",
keyspace: "aedes"
},
// Optional ttl settings
ttl: {
packets: 300, // Number of seconds
subscriptions: 300,
}
})With the previous configuration all packets will have a ttl of 300 seconds. You can also provide different ttl settings for each packet type:
ttl: {
packets: {
incoming: 100,
outgoing: 100,
will: 300,
retained: -1
}, // Number of seconds
subscriptions: 300,
}If you want a specific packet type to be persistent just set corresponding ttl to null or undefined.
Acknowledgements
Implementation inspired after aedes-persistence-mongodb.
License
MIT