Skip to main content

Class: IdempotencyKeyService

Hierarchy

  • "medusa-interfaces"

    IdempotencyKeyService

Constructors

constructor

new IdempotencyKeyService(__namedParameters)

Parameters

NameType
__namedParametersObject

Overrides

BaseService.constructor

Defined in

services/idempotency-key.js:8

Methods

create

create(payload): Promise<IdempotencyKeyModel>

Creates an idempotency key for a request. If no idempotency key is provided in request, we will create a unique identifier.

Parameters

NameTypeDescription
payloadanypayload of request to create idempotency key for

Returns

Promise<IdempotencyKeyModel>

the created idempotency key

Defined in

services/idempotency-key.js:55


initializeRequest

initializeRequest(headerKey, reqMethod, reqParams, reqPath): Promise<IdempotencyKeyModel>

Execute the initial steps in a idempotent request.

Parameters

NameTypeDescription
headerKeystringpotential idempotency key from header
reqMethodstringmethod of request
reqParamsstringparams of request
reqPathstringpath of request

Returns

Promise<IdempotencyKeyModel>

the existing or created idempotency key

Defined in

services/idempotency-key.js:29


lock

lock(idempotencyKey): Promise<any>

Locks an idempotency.

Parameters

NameTypeDescription
idempotencyKeystringkey to lock

Returns

Promise<any>

result of the update operation

Defined in

services/idempotency-key.js:94


retrieve

retrieve(idempotencyKey): Promise<IdempotencyKeyModel>

Retrieves an idempotency key

Parameters

NameTypeDescription
idempotencyKeystringkey to retrieve

Returns

Promise<IdempotencyKeyModel>

idempotency key

Defined in

services/idempotency-key.js:76


update

update(idempotencyKey, update): Promise<any>

Locks an idempotency.

Parameters

NameTypeDescription
idempotencyKeystringkey to update
updateanyupdate object

Returns

Promise<any>

result of the update operation

Defined in

services/idempotency-key.js:121


workStage

workStage(idempotencyKey, func): IdempotencyKeyModel

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

NameTypeDescription
idempotencyKeystringcurrent idempotency key
funcFunctionfunctionality to execute within the phase

Returns

IdempotencyKeyModel

new updated idempotency key

Defined in

services/idempotency-key.js:148