UNPKG

nanolith

Version:

Multi-threading in no time with seamless TypeScript support.

31 lines (30 loc) 1 kB
import type { TaskDefinitions } from './definitions.js'; import type { Service } from '../service/index.js'; export type ServiceClusterMapEntry<Definitions extends TaskDefinitions> = { service: Service<Definitions>; identifier: string; }; export type ServiceClusterMap<Definitions extends TaskDefinitions> = Map<string, ServiceClusterMapEntry<Definitions>>; export type ServiceClusterOptions = { /** * Automatically re-launch a service if its process ends with a non-zero * exit code. * * @example * // Launch five services on a cluster * const cluster = nanolith.clusterize(5, { * cluster: { * // Enable auto-renewal * autoRenew: true, * }, * }); * * await cluster.use().close(1); * * // Allow some time for the cluster to re-launch a service * await new Promise((r) => setTimeout(r, 2e3)); * * console.log(cluster.activeServices); // -> 5 */ autoRenew?: boolean; };