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

gossip-cyclon

v0.3.1

Published

Cyclon Gossip algorithm implemented in Javascript

Downloads

13

Readme

Gossip: Cyclon in Javascript

Build Status

This implements the Cyclon gossip protocol [1] for membership management.

Gossip in simple language

Imagine you have big group of people and you want to tell everybody something. You could broadcast a message by talking to each of them individually, or you could just talk to some (this is called gossip), telling them to tell other people.

Gossip protocols by Virginia Alonso

Illustration by @virginialonso

Cyclon in simple language

Cyclon is a simple gossip protocol that ensures that every peer in the network gets connected with the network of peers, without being connected to every single one. This is done by peers keeping a list of neighbors (small compared to the network) and at every interval, ask the neighbor that has been the longest in a peer list of neighbors (this is called partial view), to exchange some neighbors.

Cyclon

const CyclonPeer = require('gossip-cyclon')
const parallel = require('run-parallel')

const Alice = new CyclonPeer()
const Bob = new CyclonPeer()

Alice.addPeers([Bob.me])

parallel([
  () => Alice.listen()
  () => Bob.listen()
], (err) => {
  if (!err) {
    Alice.start()
    Bob.start()
    // This will make Alice and Bob exchange each others information every 1 second
  }
})

Run the simulation

$ git clone https://github.com/nicola/js-gossip-cyclon
$ cd js-gossip-cyclon
$ npm install
$ node viz/index.js
// Now visit http://127.0.0.1:8080

Usage

constructor

var peer = new CyclonPeer(opts)

opts can have:

  • peer: PeerInfo object of this CyclonPeer, default: new PeerInfo().
  • maxShuffle: how many peers to send during shuffling
  • maxPeers: how many peers can be stored in the list of neighboors (or .partialView)
  • interval: how often CyclonPeer should shuffle
  • peers: array of peers to bootstrap CyclonPeer (they will be added to its .partialView)

variables

peer.partialView

Partial view of the peer, this is a PeerSet

peer.peer

The current peer object, by default a PeerInfo

methods

peer.listen(cb)

Listen on its transports (by default TCP)

peer.close(cb)

Close any listener on any transport

peer.start()

Start shuffling every peer.interval

peer.stop()

Stops the repeating shuffling

peer.shuffle(cb)

Shuffle and when done calls cb (on failure or success)

peer.addPeers(peers, replace)

Add a list of peers, if the peers to be added will make .partialView grow beyond .maxPeers, the replace list will be used, otherwise drop 'em.

peer.updateAge()

Update the age of the peers in the .partialView

References

[1] S. Voulgaris, D. Gavidia, M. van Steen. CYCLON: Inexpensive Membership Management for Unstructured P2P Overlays. J. Network Syst. Manage. 13(2): 197-217 (2005)

License

MIT