Skip to main content

Class: JobEngine

Defined in: packages/client/src/core/job-engine/index.ts:214

Engine for executing background jobs in the DocStack system.

The JobEngine provides a simple interface to execute jobs by their ID. Jobs are fetched from the database, validated, and executed with full run tracking and metadata persistence.

Example

// Execute a job
const run = await stack.jobEngine.executeJob('Job-process-data', {
batchSize: 100
});

console.log('Status:', run.status);
console.log('Duration:', run.durationMs, 'ms');

Constructors

Constructor

new JobEngine(stack): JobEngine;

Defined in: packages/client/src/core/job-engine/index.ts:222

Creates a new JobEngine instance.

Parameters

ParameterTypeDescription
stackClientStackThe parent ClientStack instance

Returns

JobEngine

Methods

executeJob()

executeJob(
jobId,
runtimeArgs?,
triggerType?): Promise<JobRunModel>;

Defined in: packages/client/src/core/job-engine/index.ts:243

Executes a job by its document ID.

Parameters

ParameterTypeDefault valueDescription
jobIdstringundefinedThe job document ID (e.g., 'Job-auth')
runtimeArgs?Record<string, any>undefinedOptional parameters to pass to the job
triggerType?JobTriggerType"manual"How the job was triggered (default: 'manual')

Returns

Promise<JobRunModel>

The completed JobRunModel with execution results

Example

const authRun = await jobEngine.executeJob('Job-auth', {
password: 'secret',
salt: 'user-salt'
});
const derivedKey = authRun.finalMetadata?.derivedKey;