npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aedes-persistence-cassandra

v0.2.1

Published

Cassandra persistence for Aedes

Downloads

5

Readme

aedes-persistence-cassandra

Aedes persistence, backed by Cassandra.

See aedes-persistence for the full API, and Aedes for usage.

Disclaimer

Be sure to understand applicability and limitations before using this package in production.

In most cases aedes-persistence-mongodb should be considered a better alternative to this.

Please understand that Cassandra is not suited for implementing queues as in most cases this results in reading lots of tombstones (cassandra-anti-patterns-queues-and-queue-datasets).

This package is suitable when:

  • You have a small sets of subscriptions with low traffic
  • You already have a deployed Cassandra cluster and can't afford to deploy another persistence solution (e.g. MongoDB or Redis)
  • You are regularly performing compactions/repair on the used keyspace

Install

npm install aedes aedes-persistence-cassandra --save

or

yarn add mqemitter-kafka aedes-persistence-cassandra

Target 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 collections
    • packets: 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 to client)
  • client: Existing cassandra-driver client instance (alternative to cassandra)

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