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

tmi.js-cluster

v1.0.0-alpha.2

Published

tmi.js-cluster is a scalable cluster for tmi.js. This cluster can have multiple supervisors that can be deployed on multiple servers.

Downloads

10

Readme

Cluster System for tmi.js Twitch Bots

License Downloads NPM Version Node Version Issues Pull Requests Discord

Introduction

tmi.js-cluster is a scalable cluster for tmi.js. This cluster can have multiple supervisors that can be deployed on multiple servers.
The cluster store its data into a database and use a redis connection for the IRC command queue to join/part channels.

Features

  • Supervisor can deployed on multiple servers.
  • Use the up-to-date tmi.js client.
  • Monitoring dashboard.
  • Optimized for unverified and verified bots.
  • Multiple tmi clients.

Events

| Available | Event | Description | Parameters | |-----------------------|----------------------|--------------------------------------------------------------------------------------|-----------------------------------| | Supervisor | supervisor.ready | Supervisor is now ready. | supervisor id | | Supervisor | supervisor.error | Supervisor couldn't spawned. | supervisor id, error | | Supervisor | supervisor.terminate | Supervisor terminate started. | supervisor id | | Supervisor | supervisor.ping | Health ping for the supervisor. | supervisor id | | Supervisor | process.create | Process created. | process id | | Supervisor | process.remove | Process destroyed. | process id | | Supervisor, TmiClient | tmi.join | Will emitted when the client join a channel. error is null if no error occurred. | error, channel | | Supervisor, TmiClient | tmi.part | Will emitted when the client part a channel. error is null if no error occurred. | error, channel | | TmiClient | tmi.channels | Will emitted every process.periodicTimer ms if the tmi.js client is in open state. | array of channels (unique values) | | TmiClient | tmi.client.created | Will emitted when a new client will be created (includes the main client). | error, username, client | | TmiClient | tmi.client.deleted | Will emitted when a client will be deleted. | username, client |

tmi.client.created

  • error is null if no error occurred.
  • username is null for the main client. It's the target channel name not the bot name.
  • client contains the tmi.js (or any else) client.

Configuration

Each and every option listed below is optional.

file: String - The bot file that should be executed if a new process will be created.

redis:

  • prefix: String - Prefix for every redis key (Default: tmi-cluster:)

supervisor:

  • keyLength: Number - Set the key length for the supervisor id. The supervisor id will be generated from hostname and a random generated string. (Default: 8)
  • stale: Number - The supervisor will be marked to terminate if the last ping was more than stale seconds ago. (Default: 15)
  • updateInterval: TODO (Default: 3_000)

process:

  • stale: Number - The process will be marked to terminate if the last ping was more than stale seconds ago. (Default: 15)
  • periodicTimer: Number - After periodicTimer milliseconds the metrics will be saved into the database and queued channels will be joined or parted. (Default: 2_000)
  • timeout: Number - If the process marked to terminate, after timeout milliseconds the process will be killed. (Default: 60_000)
  • terminateUncaughtException: Boolean - If true the process will be terminated on uncaughtException. (Default: true)

multiClients:

  • enabled: Boolean - If true, then the multi client feature is enabled. You should set it to false if you don't use that to save performance. (Default: true)

metrics:

  • enabled: Boolean - If true, then metrics for every process will be generated and saved into the database. (Default: true)
  • memory: Boolean - If true, then the current memory (MB) will be saved into the metrics object. (Default: true)

autoScale:

  • processes:
    • min: Number - The minimum of processes. (Default: 2)
    • max: Number - The maximum of processes. (Default: 20)
  • thresholds:
    • channels: Number - The maximum target of channels per process. (Default: 2_000)
    • scaleUp: Number - If a supervisor reach more than scaleUp% channels then a new process will be created. (Default: 75)
    • scaleDown: Number - If a supervisor reach less than scaleUp% channels then one process will be terminated. (Default: 50)

throttle:

  • join:
    • allow: Number - The maximum allowed take value. (Default: 2_000)
    • every: Number - The time to wait before the next channels are joined. (Default: 10)
    • take: Number - The number of channels there should be joined every every seconds. Twitch allows 20/10s for normal users and 2000/10s for verified bots. (Default: 20)
  • clients:
    • allow: Number - The maximum allowed take value. (Default: 100)
    • every: Number - The time to wait before the next clients should be created. (Default: 10)
    • take: Number - The number of clients there should be created every every seconds. (Default: 50)

Default Object

{
	"file": "bot.js",
	"redis": {
		"prefix": "tmi-cluster:"
	},
	"supervisor": {
		"keyLength": 8,
		"stale": 15,
		"updateInterval": 3000
	},
	"process": {
		"stale": 15,
		"periodicTimer": 2000,
		"timeout": 60000
	},
	"multiClients": {
		"enabled": false
	},
	"metrics": {
		"enabled": true,
		"memory": true
	},
	"autoScale": {
		"processes": {
			"min": 2,
			"max": 20
		},
		"thresholds": {
			"channels": 2000,
			"scaleUp": 75,
			"scaleDown": 50
		}
	},
	"throttle": {
		"join": {
			"allow": 2000,
			"every": 10,
			"take": 20
		},
		"clients": {
			"allow": 100,
			"every": 10,
			"take": 50
		}
	}
}