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_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

complete

**complete**(batchJobOrId): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

confirm

**confirm**(batchJobOrId): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

create

**create**(data): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

listAndCount

**listAndCount**(selector?, config?): Promise&#60;[[BatchJob](/references/services/classes/BatchJob)[], number]&#62;

Parameters

selectorFilterableBatchJobPropsRequired

Default: {}

configFindConfig<BatchJob>Required

Returns

Promise<[BatchJob[], number]>

PromisePromise<[BatchJob[], number]>Required

prepareBatchJobForProcessing

**prepareBatchJobForProcessing**(data, req): Promise&#60;[CreateBatchJobInput](/references/services/types/CreateBatchJobInput)&#62;

Parameters

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

Returns

Promise<CreateBatchJobInput>

PromisePromise<CreateBatchJobInput>Required

retrieve

**retrieve**(batchJobId, config?): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobIdstringRequired
configFindConfig<BatchJob>Required

Default: {}

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setFailed

**setFailed**(batchJobOrId, error?): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired
errorstring | BatchJobResultError

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setPreProcessingDone

**setPreProcessingDone**(batchJobOrId): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

setProcessing

**setProcessing**(batchJobOrId): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

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&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

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

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

updateStatus

Protected **updateStatus**(batchJobOrId, status): Promise&#60;[BatchJob](/references/services/classes/BatchJob)&#62;

Parameters

batchJobOrIdstring | BatchJobRequired
statusBatchJobStatusRequired

Returns

Promise<BatchJob>

PromisePromise<BatchJob>Required

withTransaction

**withTransaction**(transactionManager?): [BatchJobService](/references/services/classes/BatchJobService)

Parameters

transactionManagerEntityManager

Returns

BatchJobService

BatchJobServiceBatchJobServiceRequired
Was this section helpful?