Skip to content

Worker Bootstrap

This file serves as the bootstrap entry point for starting a worker in the @sodacore/core library. It retrieves the worker file to execute from the process arguments and initializes a new WorkerWrapper instance with it.


Features

  • Worker File Resolution: Uses getThreadFileFromArgs to determine which worker file should be executed based on command-line arguments.
  • Worker Initialization: Instantiates a WorkerWrapper with the resolved worker file, starting the worker's execution.

Usage

This file is intended to be executed as a worker entry point, typically by the main process or a worker manager.

typescript
import { getThreadFileFromArgs } from '../helper/utils';
import WorkerWrapper from '../module/worker';

new WorkerWrapper(getThreadFileFromArgs());

API

  • getThreadFileFromArgs(): Parses process arguments to determine the path of the worker file to execute.

  • WorkerWrapper: Class responsible for managing the lifecycle and communication of the worker.


Notes

  • This file should not be imported directly by application code; it is meant to be run as a separate process/worker.
  • Ensures that the correct worker logic is loaded and executed based on runtime arguments.

Released under the Apache-2.0 License.