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.
37 lines (36 loc) • 1.38 kB
TypeScript
import { Worker as WorkerThread, WorkerOptions, MessagePort } from 'worker_threads';
import { SerializableInput, Serializable } from '../types';
/** Options for the worker. */
export interface WorkerThreadOptions extends WorkerOptions {
/** Data to send to the cluster. */
clusterData?: NodeJS.ProcessEnv | undefined;
}
/** Worker class. */
export declare class Worker {
private file;
/** The worker process. */
process: WorkerThread | null;
/** The options for the worker process. */
workerOptions: WorkerOptions;
/** Creates an instance of Worker. */
constructor(file: string, options: WorkerThreadOptions);
/** Spawns the worker. */
spawn(): WorkerThread;
/** Respawns the worker. */
respawn(): Promise<WorkerThread>;
/** Kills the worker. */
kill(): Promise<boolean>;
/** Sends a message to the worker. */
send<T extends Serializable>(message: SerializableInput<T, true> | unknown): Promise<void>;
}
/** Worker client class. */
export declare class WorkerClient {
/** The IPC port of the worker. */
readonly ipc: MessagePort | null;
/** Creates an instance of WorkerClient. */
constructor();
/** Respawns the worker. */
send<T extends Serializable>(message: SerializableInput<T, true> | unknown): Promise<void>;
/** Gets the data from the worker. */
getData(): unknown;
}