All Projects → DevYukine → Kurasuta

DevYukine / Kurasuta

Licence: mit
A Custom discord.js Sharding Library inspired by eris-sharder.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Kurasuta

Discord Rich Presence Tool
A C++/Qt program that lets you fill in your own custom Discord Rich Presence information for games and activities away from the PC.
Stars: ✭ 91 (-9.9%)
Mutual labels:  discord
Snow Stamp
Get the timestamp from a Discord snowflake ❄
Stars: ✭ 95 (-5.94%)
Mutual labels:  discord
Yoke
Postgres high-availability cluster with auto-failover and automated cluster recovery.
Stars: ✭ 1,360 (+1246.53%)
Mutual labels:  cluster
Prism Bukkit
Prism is a rollback/grief management tool for Bukkit
Stars: ✭ 90 (-10.89%)
Mutual labels:  discord
Nitro Generator
Discord Nitro Code Generator and Checker. Generates Classic and Boost Nitro Codes. Using HTTPS Proxy (Autoscraper)
Stars: ✭ 93 (-7.92%)
Mutual labels:  discord
Multirpc
A Discord rich presence manager app with a cool GUI and support for custom status and multiple profiles
Stars: ✭ 94 (-6.93%)
Mutual labels:  discord
Endurox
Enduro/X Middleware Platform for Distributed Transaction Processing
Stars: ✭ 91 (-9.9%)
Mutual labels:  cluster
Discord Resources
A curated list of awesome Discord modding resources
Stars: ✭ 100 (-0.99%)
Mutual labels:  discord
Scaleable Crawler With Docker Cluster
a scaleable and efficient crawelr with docker cluster , crawl million pages in 2 hours with a single machine
Stars: ✭ 96 (-4.95%)
Mutual labels:  cluster
Nats Queue Worker
Queue-worker for OpenFaaS with NATS Streaming
Stars: ✭ 98 (-2.97%)
Mutual labels:  cluster
Tidal Discord Rich Presence Unofficial
UNOFFICIAL Tidal Discord Rich Presence
Stars: ✭ 93 (-7.92%)
Mutual labels:  discord
Raspberry Pi Dramble
Raspberry Pi Kubernetes cluster that runs HA/HP Drupal 8
Stars: ✭ 1,317 (+1203.96%)
Mutual labels:  cluster
Pengubot
Official PenguBot GitHub Repository
Stars: ✭ 98 (-2.97%)
Mutual labels:  discord
Discordbot
A Java Discord bot using JDA
Stars: ✭ 92 (-8.91%)
Mutual labels:  discord
Teleport
Certificate authority and access plane for SSH, Kubernetes, web apps, databases and desktops
Stars: ✭ 10,602 (+10397.03%)
Mutual labels:  cluster
Skyra
All-in-one multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability.
Stars: ✭ 92 (-8.91%)
Mutual labels:  discord
Kcf
A CLI tool providing you with status & configuration of a Kubernetes cluster fleet
Stars: ✭ 98 (-2.97%)
Mutual labels:  cluster
Rbb Website
Website to help connect black-owned businesses with consumers and resources
Stars: ✭ 101 (+0%)
Mutual labels:  discord
Openrct2
An open source re-implementation of RollerCoaster Tycoon 2 🎢
Stars: ✭ 10,115 (+9914.85%)
Mutual labels:  discord
Mods
User-made modifications and improvements to Discord Bot Maker.
Stars: ✭ 99 (-1.98%)
Mutual labels:  discord

Kurasuta

About

Kurasuta is a powerful sharding manager for the discord.js library. It uses Node.js's cluster module to spread shards evenly among all cores.

Installation and Usage

To download Kurasuta, run npm install kurasuta If you use Yarn, run yarn add kurasuta

To use Kurasuta, you can take a look at example

ShardingManager

Important Note Your Sharder file is also executed by each cluster to access the client, client options and ipcsocket properties. You should make sure to wrap all the code what should only run on the Master process in a if statement checking if the current process is the Master process. This does not include ShardingManager#spawn.

Example:

const { isMaster } = require('cluster');

if (isMaster) {
	// Code to run on the Master process here
}

Name Description
path path to a file that exports a class extending Cluster. The class must contain a method called launch.
options.clientOptions An object of client options you want to pass to the Discord.js client constructor.
options.clusterCount The number of how many clusters you want. Defaults to the amount of cores.
options.shardCount The number of how many shards you want. Defaults to the amount that the gateway recommends, taking options.guildsPerShardinto account.
options.development Boolean to enable development mode.
options.client Class extending the Discord.js client you want to use for your clusters (useful for Frameworks like Commando, Klasa, or Akairo). Defaults to Discord.js client.
options.guildsPerShard Number to calculate how many guilds per shard. Defaults to 1000. Ignored if you set shardCount.
options.respawn Boolean indicating if exited Clusters should always get restarted. Defaults to true .
options.ipcSocket Path to Socket or Port that should be used for IPC connections. Defaults to Port 9999.
options.token Token that should be used to fetch the recommend Shard count if no Shard count was provided.
options.timeout Time per shard to wait before assuming that a Cluster can't get ready in ms. Defaults to 30000
option.retry Boolean indicating if Clusters which fail to start but not exit should be restarted. Defaults to true

Events

Name Argument(s) Description
debug message: string Emitted for debug messages
message message: unknown Emitted for custom messages sent from Cluster to Manager
ready cluster: Cluster Emitted when a Cluster becomes ready
spawn cluster: Cluster Emitted when a Cluster spawns
shardReady shardID: number Emitted when a Shard becomes ready
shardReconnect shardID: number Emitted when a Shard reconnects
shardResume replayed: number, shardID: number Emitted when a Shard resumes
shardDisconnect closeEvent: CloseEvent, shardID: number Emitted when a Shard disconnects

Cluster

In every cluster when your code is loaded, you get access to this.client and this.id. this.client is an instance of the Client you provided with nearly no modifications besides the shard property, Discord.js' build-in ShardClientUtil is replaced by Kurasuta's.

ShardClientUtil

Method Example Description Returns
broadcastEval client.shard.broadcastEval(script); Evals a script on all clusters in context of the Client. Promise<unkown[]>
masterEval client.shard.masterEval(script); Evals a script on the master process in context of the ShardingManager. Promise<unkown>
fetchClientValues client.shard.fetchClientValues(prop); Fetch a Client value on all clusters. Promise<unkown[]>
restartAll client.shard.restartAll(); Sends a message to the master process to kill & restart all clusters. Promise<void>
restart client.shard.restart(clusterID); Restart a specific cluster by id. Promise<void>
send client.shard.send(data, options); send a message to the master process. Promise<void>

Example

Directory Tree

In this example our setup looks like this:

Project/
├── node-modules/
│   └── kurasuta/
|
└── src/
    ├── main.js
    └── index.js

Example of main.js

const { BaseCluster } = require('kurasuta');

module.exports = class extends BaseCluster {
	launch() {
		this.client.login('YOUR_TOKEN_HERE');
	}
};

Example of index.js

const { ShardingManager } = require('kurasuta');
const { join } = require('path');
const sharder = new ShardingManager(join(__dirname, 'main'), {
	// your options here
});

sharder.spawn();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].