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
| Parameter | Type | Description |
|---|---|---|
stack | ClientStack | The 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
jobId | string | undefined | The job document ID (e.g., 'Job-auth') |
runtimeArgs? | Record<string, any> | undefined | Optional 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;