workerInfo
Tells which process the caller runs in.
Tells which process the caller runs in. In a worker of a pool (serve({ workers }), dusk start --workers) it reports the
worker's id and the size of the pool; in a single process it reports clustered: false and a count of 1. Use it to
keep state that must be shared out of a worker's memory, or to label logs.
Import#
ts
import { workerInfo } from "@shadow-js/dusk/node";
Signature#
ts
function workerInfo(): WorkerInfo
Returns#
The worker information.
Examples#
ts
import { workerInfo } from "@shadow-js/dusk/node";
const { clustered, id, count } = workerInfo();
if (clustered) console.log(`worker ${id} of ${count}`);