Git Product home page Git Product logo

kad-quasar's Introduction

Kad Quasar

Build Status Coverage Status NPM

Publish/Subscribe extension system for Kad, based on Quasar.

Quick Start

Install kad-quasar with NPM:

npm install kad kad-quasar --save

Give kad-quasar your kad.Router:

var quasar = require('kad-quasar');
var topics = new quasar.Protocol(router);

topics.subscribe('beep', function(content) {
  console.log(content); // { "message": "boop" }
});

topics.publish('beep', {
  message: 'boop'
});

Overview

Please note that this software is alpha stage and may not be suitable for production systems.

Kad Quasar extends Kad with a publish/subscribe system, enabling different applications to run on the same overlay network.

To do this, Kad Quasar uses the kad.Router object's contact list to build an attenuated 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: Quasar(kad.Router)

The Quasar class implements Quasar: A Probabilistic Publish-Subscribe System, given an instance of kad.Router. It creates and manages an attenuated bloom filter representing the different topics to which your neighboring nodes are subscribed.

q.publish(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

q.subscribe(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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.