# kad-quasar

> publish-subscribe system for kad

Latest version **2.1.0** (published 2017-06-24) · AGPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install kad-quasar
pnpm add kad-quasar
yarn add kad-quasar
bun add kad-quasar
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2017-06-24 |
| First published | 2016-01-22 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.9.1 |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Gordon Hall |
| Maintainers | bookchin |
| Keywords | kad, publish, subscribe, pubsub, sensor, network |

## Links

- npm: https://www.npmjs.com/package/kad-quasar
- Repository: https://github.com/kadtools/kad-quasar
- Homepage: https://github.com/kadtools/kad-quasar#readme
- Issues: https://github.com/kadtools/kad-quasar/issues
- npm.io page: https://npm.io/package/kad-quasar

## Dependencies (7)

- [kad](https://npm.io/package/kad.md) ^2.3.0
- [atbf](https://npm.io/package/atbf.md) ^1.1.0
- [uuid](https://npm.io/package/uuid.md) ^3.0.0
- [async](https://npm.io/package/async.md) ^2.1.4
- [merge](https://npm.io/package/merge.md) ^1.2.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^4.0.1
- [knuth-shuffle](https://npm.io/package/knuth-shuffle.md) ^1.0.1

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 2.1.0 (latest) — 2017-06-24
- 2.0.3 — 2017-06-14
- 2.0.2 — 2017-05-30
- 2.0.1 — 2017-05-23
- 1.2.4 — 2017-05-23
- 2.0.0 — 2017-03-20
- 1.2.3 — 2017-02-22
- 1.2.2 — 2017-02-19
- 1.2.1 — 2017-02-19
- 1.2.0 — 2017-02-17
- 1.1.0 — 2017-02-13
- 1.0.2 — 2016-11-08
- 1.0.1 — 2016-10-24
- 1.0.0 — 2016-10-24
- 0.3.3 — 2016-10-15
- … 11 more at https://npm.io/package/kad-quasar/versions

## README

Kad Quasar
==========

[![Build Status](https://img.shields.io/travis/kadtools/kad-quasar.svg?style=flat-square)](https://travis-ci.org/kadtools/kad-quasar)
[![Coverage Status](https://img.shields.io/coveralls/kadtools/kad-quasar.svg?style=flat-square)](https://coveralls.io/r/kadtools/kad-quasar)
[![NPM](https://img.shields.io/npm/v/kad-quasar.svg?style=flat-square)](https://www.npmjs.com/package/kad-quasar)

Distributed publish-subscribe plugin for [Kad](https://github.com/kadtools/kad),
based on [Quasar](http://research.microsoft.com/en-us/um/people/saikat/pub/iptps08-quasar.pdf).

Quick Start
-----------

Install kad-quasar with NPM:

```bash
npm install kad-quasar --save
```

Plugin to your existing Kad project:

```js
const kad = require('kad');
const quasar = require('kad-quasar');
const node = kad({ /* options */ });

node.plugin(quasar);

node.quasarSubscribe('topic string', (content) => {
  node.logger.info(content);
});

node.quasarPublish('topic string', {
  some: 'content'
});
```

Overview
--------

Kad Quasar extends [Kad](https://github.com/kadtools/kad) with a [publish/subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)
system, enabling different applications to run on the same overlay network.

To do this, Kad Quasar uses the routing table's contact list to build an
attenuated [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) where each
filter in the series contains topics that your node and your neighbors are
subscribed to represented in "hops" from your node.

This allows each node to maintain a view of what their neighbors are interested
in 3 hops away. Published messages are relayed to neighbors probabilistically
based on this knowledge and are appended with negative information to prevent
duplication. This forms "gravity wells" in the network around groups who are
interested in a given topic and serves to prevent flooding the network while
still maintaining a high probability that the message will be delivered to all
nodes interested.

Class: QuasarNode(options)
--------------------------

The `QuasarNode` class decorates the 
[`KademliaNode`](https://kadtools.github.io/KademliaNode.html) class in Kad. 
It creates and manages an attenuated bloom filter representing the different 
topics to which your neighboring nodes are subscribed.

### node.quasarPublish(topic[, content])

Publishes a message to your nearest neighbors on the given `topic` (and
optional) `content` object. Those neighbors, in turn, relay the message to
their neighbors in accordance with their view of the the network.

#### Parameters

* `topic` - (String) identifier for the topic
* `content` - (Mixed) additional data describing the publication

### node.quasarSubscribe(topic[, handler])

Updates our local attenuated bloom filter to reflect our interest in the topic
and notifies our neighbors to relay publications matching the topic to us. In
turn, our neighbors will provide us with their local bloom filter, so we can do
the same.

#### Parameters

* `topic` - (String) identifier for the topic
* `handler` - (Function) receives arguments `content` with published data

License
-------

Kad Quasar - Distributed publish-subscribe plugin for Kad  
Copyright (C) 2017 Gordon Hall

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.

---
_Source: https://npm.io/package/kad-quasar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
