-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: [AEA-3861] - Provide error response if data store update time…
…s out (#146) ## Summary 🎫 [AEA-3861](https://nhsd-jira.digital.nhs.uk/browse/AEA-3861) Provide error response if data store update times out - Routine Change ### Details The solution must ensure that the OperationOutcome relating to timed out request contains an issue resource constructed using the 504 error code in the case where the DynomoDB request times out. See timeout requirement in [NPPTS NFR Specification](https://nhsd-confluence.digital.nhs.uk/display/APIMC/NPPT+Service+-+Non-functional+Requirements).
- Loading branch information
1 parent
d2e1dbf
commit fae978d
Showing
9 changed files
with
95 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/updatePrescriptionStatus/src/utils/timeoutUtils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export interface Timeout { | ||
isTimeout: true | ||
} | ||
|
||
export async function jobWithTimeout<T>(timeoutMS: number, job: Promise<T>): Promise<T | Timeout> { | ||
const timeoutPromise: Promise<Timeout> = new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve({isTimeout: true}) | ||
}, timeoutMS) | ||
}) | ||
return Promise.race([job, timeoutPromise]) | ||
} | ||
|
||
export function hasTimedOut<T>(response: T | Timeout): response is Timeout { | ||
return !!(response as Timeout)?.isTimeout | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters