@camunda8/sdk
Version:
[](https://www.npmjs.com/package/@camunda8/sdk)
57 lines (56 loc) • 2.41 kB
TypeScript
import { ZeebeGrpcClient } from '../zb/ZeebeGrpcClient';
import { StatefulLogInterceptor } from './StatefulLogInterceptor';
import { IZBJobWorker, Job, JobCompletionInterface, ZBGrpc, ZBWorkerTaskHandler } from './interfaces-1.0';
import { StreamActivatedJobsRequest } from './interfaces-grpc-1.0';
export declare class ZBStreamWorker implements IZBJobWorker {
private grpcClient;
private logger;
private zbClient;
private streams;
private pollTimers;
constructor({ grpcClient, log, zbClient, }: {
grpcClient: ZBGrpc;
log: StatefulLogInterceptor;
zbClient: ZeebeGrpcClient;
});
streamJobs<WorkerInputVariables, CustomHeaderShape, WorkerOutputVariables>(req: StreamActivatedJobsRequest & {
inputVariableDto: {
new (...args: any[]): Readonly<WorkerInputVariables>;
};
customHeadersDto: {
new (...args: any[]): Readonly<CustomHeaderShape>;
};
taskHandler: ZBWorkerTaskHandler<WorkerInputVariables, CustomHeaderShape, WorkerOutputVariables>;
/**
* Optional jitter in milliseconds. When provided, the worker will wait
* a random period up to this value before polling and opening the stream.
* Useful for staggering multiple stream workers.
*/
jitter?: number;
/**
* Maximum number of jobs to activate per poll cycle (both the initial
* backfill and the recurring sidecar polls). Defaults to 32.
*/
pollMaxJobsToActivate?: number;
/**
* Interval in milliseconds between sidecar poll cycles. The sidecar poll
* is a low-frequency safety net that picks up jobs the stream may have
* missed (e.g. jobs re-queued after a timeout). Each poll is a command on
* the broker, so keep this value high to minimise load.
*
* Defaults to 30000 (30 seconds). Set to 0 or -1 to disable recurring
* polling (the initial backfill poll still runs).
*/
pollInterval?: number;
}): Promise<{
close: () => void;
}>;
close(): Promise<void>;
log(msg: JSON): void;
debug(msg: JSON): void;
error(msg: JSON): void;
protected makeCompleteHandlers<T>(thisJob: Job, taskType: string): JobCompletionInterface<T> & JobCompletionInterface<T>;
private failJob;
private completeJob;
private errorJob;
}