Skip to main content
Skip to main content

BatchJobService

Constructors

constructor

new BatchJobService(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
batchJobRepository_Repository<BatchJob>Required
batchJobStatusMapToPropsMap<BatchJobStatus, { entityColumnName: string ; eventType: string }>Required
eventBus_EventBusServiceRequired
manager_EntityManagerRequired
strategyResolver_StrategyResolverServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CANCELEDstringRequired

Default: "batch.canceled"

Events.COMPLETEDstringRequired

Default: "batch.completed"

Events.CONFIRMEDstringRequired

Default: "batch.confirmed"

Events.CREATEDstringRequired

Default: "batch.created"

Events.FAILEDstringRequired

Default: "batch.failed"

Events.PRE_PROCESSEDstringRequired

Default: "batch.pre_processed"

Events.PROCESSINGstringRequired

Default: "batch.processing"

Events.UPDATEDstringRequired

Default: "batch.updated"

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Methods

atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

cancel

cancel(batchJobOrId): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

complete

complete(batchJobOrId): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

confirm

confirm(batchJobOrId): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

create

create(data): Promise<BatchJob>

Parameters

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

listAndCount

listAndCount(selector?, config?): Promise<[BatchJob[], number]>

Parameters

selectorFilterableBatchJobPropsRequired

Default: {}

configFindConfig<BatchJob>Required

Returns

Promise<[BatchJob[], number]>

PromisePromise<[BatchJob[], number]>Required

prepareBatchJobForProcessing

prepareBatchJobForProcessing(data, req): Promise<CreateBatchJobInput>

Parameters

reqRequest<ParamsDictionary, any, any, ParsedQs, Record<string, any>>Required

Returns

Promise<CreateBatchJobInput>

PromisePromise<CreateBatchJobInput>Required

retrieve

retrieve(batchJobId, config?): Promise<BatchJob>

Parameters

batchJobIdstringRequired
configFindConfig<BatchJob>Required

Default: {}

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setFailed

setFailed(batchJobOrId, error?): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired
errorstring | BatchJobResultError

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setPreProcessingDone

setPreProcessingDone(batchJobOrId): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setProcessing

setProcessing(batchJobOrId): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

update

update(batchJobOrId, data): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired
dataPartial<Pick<BatchJob, "context" | "result">>Required

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

updateStatus

Protected updateStatus(batchJobOrId, status): Promise<BatchJob>

Parameters

batchJobOrIdstring | BatchJobRequired
statusBatchJobStatusRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

withTransaction

withTransaction(transactionManager?): BatchJobService

Parameters

transactionManagerEntityManager

Returns

BatchJobService

BatchJobServiceBatchJobServiceRequired
Was this section helpful?