IdempotencyKeyService
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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.
Type Parameters
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>Requiredthe transactional work to be done
isolationOrErrorHandler
IsolationLevel | (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
Promise<TResult>Requiredthe result of the transactional work
initializeRequest
Execute the initial steps in a idempotent request.
Parameters
headerKey
stringRequiredpotential idempotency key from header
reqMethod
stringRequiredmethod of request
reqParams
Record<string, unknown>Requiredparams of request
reqPath
stringRequiredpath of request
Returns
the existing or created idempotency key
create
Creates an idempotency key for a request. If no idempotency key is provided in request, we will create a unique identifier.
Parameters
payload
CreateIdempotencyKeyInputRequiredpayload of request to create idempotency key for
Returns
the created idempotency key
retrieve
Retrieves an idempotency key
Parameters
key or selector to retrieve
Returns
idempotency key
lock
Locks an idempotency.
Parameters
idempotencyKey
stringRequiredkey to lock
Returns
result of the update operation
update
Locks an idempotency.
Parameters
idempotencyKey
stringRequiredkey to update
update object
Returns
result of the update operation
workStage
Performs an atomic work stage. An atomic work stage contains some related functionality, that needs to be transactionally executed in isolation. An idempotent request will always consist of 2 or more of these phases. The required phases are "started" and "finished".
Parameters
idempotencyKey
stringRequiredcurrent idempotency key
callback
(transactionManager: EntityManager) => Promise<IdempotencyCallbackResult>Requiredfunctionality to execute within the phase
Returns
new updated idempotency key
Was this section helpful?