Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
interface Cluster
implements EventEmitter
import { type Cluster } from "https://deno.land/std@0.172.0/node/internal/cluster/types.ts";

Properties

readonly
isPrimary: boolean
readonly
deprecated
isMaster: boolean
readonly
isWorker: boolean
readonly
settings: ClusterSettings
readonly
optional
worker: Worker | null
readonly
optional
Worker: WorkerClass
readonly
optional
workers: Record<number, Worker>
readonly
SCHED_NONE: number
readonly
SCHED_RR: number
schedulingPolicy: number
optional
_setupWorker: () => void
optional
_getServer: (
obj: any,
options: { address?: string | null; port?: number | null; addressType?: string | number | null; fd?: number | null; flags?: number | null; },
cb: (err: number, handle: any) => void,
) => void

Methods

disconnect(callback?: () => void): void
fork(env?: Record<string | number, unknown>): Worker
deprecated
setupMaster(settings?: ClusterSettings): void
setupPrimary(settings?: ClusterSettings): void

setupPrimary is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.

addListener(event: string, listener: (...args: unknown[]) => void): this

events.EventEmitter

  1. disconnect
  2. exit
  3. fork
  4. listening
  5. message
  6. online
  7. setup
addListener(event: "disconnect", listener: (worker: Worker) => void): this
addListener(event: "exit", listener: (
worker: Worker,
code: number,
signal: string,
) => void
): this
addListener(event: "fork", listener: (worker: Worker) => void): this
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this
addListener(event: "message", listener: (
worker: Worker,
message: unknown,
handle: any,
) => void
): this
addListener(event: "online", listener: (worker: Worker) => void): this
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this
emit(event: string | symbol, ...args: unknown[]): boolean
emit(event: "disconnect", worker: Worker): boolean
emit(
event: "exit",
worker: Worker,
code: number,
signal: string,
): boolean
emit(event: "fork", worker: Worker): boolean
emit(
event: "listening",
worker: Worker,
address: Address,
): boolean
emit(
event: "message",
worker: Worker,
message: unknown,
handle: any,
): boolean
emit(event: "online", worker: Worker): boolean
emit(event: "setup", settings: ClusterSettings): boolean
on(event: string, listener: (...args: unknown[]) => void): this
on(event: "disconnect", listener: (worker: Worker) => void): this
on(event: "exit", listener: (
worker: Worker,
code: number,
signal: string,
) => void
): this
on(event: "fork", listener: (worker: Worker) => void): this
on(event: "listening", listener: (worker: Worker, address: Address) => void): this
on(event: "message", listener: (
worker: Worker,
message: unknown,
handle: any,
) => void
): this
on(event: "online", listener: (worker: Worker) => void): this
on(event: "setup", listener: (settings: ClusterSettings) => void): this
once(event: string, listener: (...args: unknown[]) => void): this
once(event: "disconnect", listener: (worker: Worker) => void): this
once(event: "exit", listener: (
worker: Worker,
code: number,
signal: string,
) => void
): this
once(event: "fork", listener: (worker: Worker) => void): this
once(event: "listening", listener: (worker: Worker, address: Address) => void): this
once(event: "message", listener: (
worker: Worker,
message: unknown,
handle: any,
) => void
): this
once(event: "online", listener: (worker: Worker) => void): this
once(event: "setup", listener: (settings: ClusterSettings) => void): this
prependListener(event: string, listener: (...args: unknown[]) => void): this
prependListener(event: "disconnect", listener: (worker: Worker) => void): this
prependListener(event: "exit", listener: (
worker: Worker,
code: number,
signal: string,
) => void
): this
prependListener(event: "fork", listener: (worker: Worker) => void): this
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this
prependListener(event: "message", listener: (
worker: Worker,
message: unknown,
handle?: any,
) => void
): this
prependListener(event: "online", listener: (worker: Worker) => void): this
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this
prependOnceListener(event: string, listener: (...args: unknown[]) => void): this
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this
prependOnceListener(event: "exit", listener: (
worker: Worker,
code: number,
signal: string,
) => void
): this
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this
prependOnceListener(event: "message", listener: (
worker: Worker,
message: unknown,
handle: any,
) => void
): this
prependOnceListener(event: "online", listener: (worker: Worker) => void): this
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this