IdempotencyKeyService
Constructors
constructor
new IdempotencyKeyService(«destructured»
)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>Requiredcreate
create(payload
): Promise
<IdempotencyKey
>
Creates an idempotency key for a request. If no idempotency key is provided in request, we will create a unique identifier.
Parameters
Returns
Promise
<IdempotencyKey
>
initializeRequest
initializeRequest(headerKey
, reqMethod
, reqParams
, reqPath
): Promise
<IdempotencyKey
>
Execute the initial steps in a idempotent request.
Parameters
headerKey
stringRequiredreqMethod
stringRequiredreqParams
Record<string, unknown>RequiredreqPath
stringRequiredReturns
Promise
<IdempotencyKey
>
lock
lock(idempotencyKey
): Promise
<IdempotencyKey
>
Locks an idempotency.
Parameters
idempotencyKey
stringRequiredReturns
Promise
<IdempotencyKey
>
retrieve
retrieve(idempotencyKeyOrSelector
): Promise
<IdempotencyKey
>
Retrieves an idempotency key
Parameters
Returns
Promise
<IdempotencyKey
>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
update(idempotencyKey
, update
): Promise
<IdempotencyKey
>
Locks an idempotency.
Parameters
idempotencyKey
stringRequiredReturns
Promise
<IdempotencyKey
>
withTransaction
withTransaction(transactionManager?
): IdempotencyKeyService
Parameters
transactionManager
EntityManagerReturns
workStage
workStage(idempotencyKey
, callback
): Promise
<IdempotencyKey
>
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
stringRequiredReturns
Promise
<IdempotencyKey
>