UNPKG

status-sharding

Version:

Welcome to Status Sharding! This package is designed to provide an efficient and flexible solution for sharding Discord bots, allowing you to scale your bot across multiple processes or workers.

41 lines (40 loc) 1.5 kB
import { ChildProcess, ForkOptions } from 'child_process'; import { SerializableInput, Serializable } from '../types'; export interface ChildProcessOptions extends ForkOptions { /** Data to send to the cluster. */ clusterData?: NodeJS.ProcessEnv | undefined; /** The arguments to pass to the child process. */ args?: string[] | undefined; } export declare class Child { private file; /** The child process. */ process: ChildProcess | null; /** The options for the child process. */ processOptions: ForkOptions & { args?: string[]; }; /** Type-safe listener manager */ private _listeners; /** Creates an instance of Child. */ constructor(file: string, options: ChildProcessOptions); /** Spawns the child process. */ spawn(): ChildProcess; /** Respawns the child process. */ respawn(): Promise<ChildProcess>; /** Kills the child process with proper cleanup. */ kill(): Promise<boolean>; /** Clean up process and listeners */ private _cleanup; /** Sends a message to the child process. */ send<T extends Serializable>(message: SerializableInput<T, true>): Promise<void>; } /** Child client class. */ export declare class ChildClient { /** The IPC process. */ readonly ipc: NodeJS.Process; /** Creates an instance of ChildClient. */ constructor(); /** Sends a message to the child process. */ send<T extends Serializable>(message: SerializableInput<T, true>): Promise<void>; }