Skip to content

Latest commit

 

History

History
144 lines (133 loc) · 8.05 KB

README.md

File metadata and controls

144 lines (133 loc) · 8.05 KB

jobhub Extended API

Typedef

HubManagerOptions : object

Configuration options for the HubManager.

JobConfig : object

Configuration for a job.

A job can be defined in two ways:

  1. Just a function, which is the code that will run in the child process.
  2. An object that has at a minimum of a JobConfig#run function, which is the code that will run in the child process.
JobRunArg : object

Passed to JobConfig#run and JobConfig#quickRun to provide information about the job and facilitate communicate progress/success/failure.

JobExecutorBuiltinOptions : object

Configuration options for JobExecutorBuiltin.

Classes

HubManager

Manages the lifecycle of jobs.

JobConfigStore

Manages registered job config.

JobExecutor

Manages running jobs that have been queued using HubManager#queueJob.

JobExecutorBuiltinJobExecutor

Manages running jobs that have been queued using HubManager#queueJob.

JobWorkerEventEmitter

Responsible for running the job in the forked worker process.

JobWorkerIPCJobWorker

Responsible for running the job in the forked worker process, receiving configuration and sending events via an IPC messages.

JobWorkerIPCMediatorJobWorkerMediator

Manages a job's forked process during it's normal lifecycle.

JobWorkerMediatorEventEmitter

Responsible for forking the job's child worker process and mediating communication with it.

MiddlewareStore

Plugins to customize functionality of jobhub.

TrackedJobEventEmitter

Tracks a job that has not yet completed.

Error Classes

InvalidManagerOptionsErrorError

An InvalidManagerOptionsError object indicates an error with the options provided to HubManager.

JobAlreadyExistsErrorError

A JobAlreadyExistsError object indicates that a job config has already been registered for a specific name.

JobNotFoundErrorError

A JobNotFoundError object indicates that a job config could not be found for a specific name.

InvalidJobConfigErrorError

An InvalidJobConfigError object indicates that a JobConfig has an invalid value for a specific property.

InvalidUniqueKeyErrorError

An InvalidUniqueKeyError object indicates that a JobConfig#uniqueKey returned an invalid value.

JobForkErrorError

A JobForkError object indicates that a forked job encountered an error.

JobAbortedErrorError

A JobAbortedError object indicates that a forked job has been aborted by calling TrackedJob#abort.

InvalidJobParamErrorError

A InvalidJobParamError object indicates that params did not validate for a specific JobConfig.

UnsupportedMiddlewareTypeErrorError

A UnsupportedMiddlewareTypeError object indicates that middleware was attempted to be used that is not supported.

JobWorkerHandlerErrorError

A JobWorkerHandlerError indicates that an error was caught while handling the successful or failed result of a job.

Middleware

loadJobs(jobs, next)

Intercepts loading and registering of jobs from HubManagerOptions#jobsModulePath by HubManager#start.

createJob(jobId, jobConfig, params, next)

Intercepts creating a TrackedJob instance.

workerLoadJob(jobs, jobName)

Intercepts creation of the JobRunArg provided to JobConfig#run.

workerBuildJobArg(jobId, params, resolve, reject, sendProgress, onAbort)JobRunArg

Intercepts creation of the JobRunArg provided to JobConfig#run.

forkJobProcess(forkModulePath, forkArgs, forkOpts, next)ChildProcess

Intercepts forking the local child process using require("child_process").fork.

buildForkArgs(trackedJob, next)Array.<string>

Intercepts creation of args provided to forkJobProcess.

buildForkOpts(trackedJob, next)object

Intercepts creation of opts provided to forkJobProcess.

createWorkerMediator(trackedJob, next)JobWorkerMediator

Intercepts creation of the JobWorkerMediator set to TrackedJob#workerMediator.

Modules

jobhub/lib/util

Helper utilities used by jobhub.

jobhub/lib/worker

Built-in node script for running job worker child processes.