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

ssb-replication-limiter

v1.0.5

Published

[![Build Status](https://travis-ci.org/ssbc/ssb-replication-limiter.svg?branch=master)](https://travis-ci.org/ssbc/ssb-replication-limiter)

Downloads

8

Readme

Build Status

ssb-replication-limiter

Limit and prioritise ebt replication for ssb.

ssb-ebt only exposes an api to stop or start replication of a feed. This module enhances it so you can control the maximum number of simultaneous downloads and prioritise who gets replicated first.

The limiter has two modes: unlimited and limited. In unlimited mode the module doesn't really do anything, it's just ordinary ebt replication.

In limited mode, only a certain number of feeds are allowed to be replicating at once.

This module tracks how far behind all feeds are. If your local copies are a long way behind then you have to do a lot of downloading to do. If a feed is more than threshold (modeChangeThreshold) behind, the module changes mode to limited mode.

In limited mode, only a set number (maxNumConnections) of feeds will be replicated simultaneously.

It's also possible to prioritise which feeds are replicated first in limited mode. See the third argument of the request function.

API

Init

var ReplicationLimiter = require('ssb-replication-limiter')
var replicationLimiter = ReplicationLimiter(opts)

Takes an opts object of shape:

{
  peerStatus: <function> (required)
  request: <function> (required)

  maxNumConnections: <num>,
  modeChangeThreshold: <num>,
}

replicationLimiter has four methods:

replicationLimiter.request(feedId, isReplicationEnabled, [priority])

Same as ssb-ebt's request method. priority is optional and defaults to 0. The higher the number, the sooner it will be replicated.

replicationLimiter.setModeChangeThreshold(threshold)

Sets a new mode change threshold.

replicationLimiter.setMaxNumConnections(max)

Sets a new maximum number of connections allowed when in limited mode.

replicationLimiter.isReplicationEnabled()

isReplicationEnabled is an observable

Sets listener-function as a new observer of isReplicationEnabled

listener-function will be called with a boolean when the mode changes.

Install

With npm installed, run

$ npm install ssb-replication-limiter

Acknowledgments

This project is funded by a grant from staltz for the manyverse project.

See Also

License

MIT