pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/moscajs/aedes-cached-persistence

ossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-b48faa60c69660fa.css" /> GitHub - moscajs/aedes-cached-persistence: Abstract class to write an Aedes persistence with in-process caching of subscriptions · GitHub
Skip to content

moscajs/aedes-cached-persistence

Repository files navigation

aedes-cached-persistence


Known Vulnerabilities Coverage Status NPM version NPM downloads

This module has been superseded by aedes-persistence


Abstract class to write an Aedes persistence with in-process caching of subscriptions. It implements the API defined by aedes-persistence.

Install

To install aedes-cached-persistence, simply use npm:

npm install aedes-cached-persistence --save

Provided methods

Implement another persistence

Inheritance

In order to reuse aedes-cached-persistence, you need to:

const CachedPersistence = require('aedes-cached-persistence')

// if you need http://npm.im/aedes-packet, it is available
// from this module as well
// const { Packet } = CachedPersistence

class MyPersistence extends CachedPersistence {
    constructor(opts) {
       super(opts)
    }
    addSubscriptions(client, subs, cb) {
        // ..persistence specific implementation..
        // call super._addedSubscriptions when you are done
        super._addedSubscriptions(client, subs.map(mapSub), cb)
    }
    removeSubscriptions(client, subs, cb) {
        // ..persistence specific implementation..
        // call super._removedSubscriptions when you are done
        super._removedSubscriptions(client, subs.map(mapSub), cb)
    }
}

function mapSub (sub) {
  return { topic: sub.topic }
}

Tests

A persistence needs to pass all tests defined in ./abstract.js. You can import and use that test suite in the following manner:

const test = require('node:test')
const myperst = require('./')
const abs = require('aedes-cached-persistence/abstract')

abs({
  test: test,
  persistence: myperst
})

If you require some async stuff before returning, a callback is also supported:

const test = require('node:test')
const myperst = require('./')
const abs = require('aedes-persistence/abstract')
const clean = require('./clean') // invented module

abs({
  test: test,
  buildEmitter: require('mymqemitter'), // optional
  persistence: function build (cb) {
    clean(function (err) {
      cb(err, myperst())
    })
  }
})

License

MIT

About

Abstract class to write an Aedes persistence with in-process caching of subscriptions

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy