-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3260 - CAS Integration 3A - Create new Supplier and Site - Retry on Error and Scheduler Time #3830
Changes from 7 commits
0d22c4d
8b9e6f5
62a228e
f4fe18e
b53cb5a
ffb85e7
7433a3c
2fdbd65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class UpdateCASSupplierIntegrationScheduler1729785100207 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Update-cas-supplier-integration.sql", "Queue"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Rollback-update-cas-supplier-integration.sql", "Queue"), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
UPDATE | ||
sims.queue_configurations | ||
SET | ||
queue_configuration = '{ | ||
"cron": "0 7 * * *", | ||
"retry": 3, | ||
"cleanUpPeriod": 2592000000, | ||
"retryInterval": 180000, | ||
"dashboardReadonly": false | ||
}' :: json | ||
WHERE | ||
queue_name = 'cas-supplier-integration'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
UPDATE | ||
sims.queue_configurations | ||
SET | ||
queue_configuration = '{ | ||
"cron": "0 19 * * 1-5", | ||
"retry": 3, | ||
"cleanUpPeriod": 2592000000, | ||
"retryInterval": 180000, | ||
"dashboardReadonly": false | ||
}' :: json | ||
WHERE | ||
queue_name = 'cas-supplier-integration'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ import { | |
logProcessSummaryToJobLogger, | ||
getSuccessMessageWithAttentionCheck, | ||
} from "../../../utilities"; | ||
import { CAS_AUTH_ERROR } from "@sims/integrations/constants"; | ||
|
||
@Processor(QueueNames.CASSupplierIntegration) | ||
export class CASSupplierIntegrationScheduler extends BaseScheduler<void> { | ||
|
@@ -63,19 +62,16 @@ export class CASSupplierIntegrationScheduler extends BaseScheduler<void> { | |
`Records updated: ${suppliersUpdated}.`, | ||
], | ||
processSummary, | ||
{ throwOnError: true }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
); | ||
} catch (error: unknown) { | ||
// Throw an error to force the queue to retry. | ||
if (error instanceof CustomNamedError) { | ||
if (error.name === CAS_AUTH_ERROR) { | ||
// Throw an error to force the queue to retry. | ||
throw new Error( | ||
`Unable to request data to CAS due to an authentication error.`, | ||
); | ||
} | ||
const errorMessage = "Unexpected error while executing the job."; | ||
processSummary.error(errorMessage, error); | ||
return [errorMessage]; | ||
throw new Error(error.message); | ||
sh16011993 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
throw new Error("Unexpected error while executing the job.", { | ||
cause: error, | ||
}); | ||
} finally { | ||
this.logger.logProcessSummary(processSummary); | ||
await logProcessSummaryToJobLogger(processSummary, job); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,11 @@ const ASCII_INDIRECT_CONVERSIONS: Record<string, string> = { | |
* Converts input into an ASCII 7 bit buffer replacing special characters | ||
* by equivalent ASCII characters when possible. | ||
* @param rawContent raw content in string format. | ||
* @returns a string of the input with extended ASCII characters (ISO-8859-1) | ||
* @returns a buffer of the input with extended ASCII characters (ISO-8859-1) | ||
* converted to equivalent ASCII characters. If null or undefined is provided, | ||
* null will be returned. | ||
*/ | ||
export function convertToASCII(rawContent?: string): string | null { | ||
export function convertToASCII(rawContent?: string): Buffer | null { | ||
if (rawContent === null || rawContent === undefined) { | ||
return null; | ||
} | ||
|
@@ -140,5 +140,17 @@ export function convertToASCII(rawContent?: string): string | null { | |
} | ||
} | ||
} | ||
return content.toString(); | ||
return content; | ||
} | ||
|
||
/** | ||
* Converts input into an ASCII 7 bit buffer replacing special characters | ||
* by equivalent ASCII characters when possible. | ||
* @param rawContent raw content in string format. | ||
* @returns a string of the input with extended ASCII characters (ISO-8859-1) | ||
* converted to equivalent ASCII characters. If null or undefined is provided, | ||
* null will be returned. | ||
*/ | ||
export function convertToASCIIString(rawContent?: string): string | null { | ||
return convertToASCII(rawContent)?.toString() ?? null; | ||
Comment on lines
+154
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for raising the issue 😉 |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AC says noon. Either we can have the AC updated or change here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. I missed the PT part. As we discussed noon PST should be 8PM UTC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad too. All schedulers on wiki are using PST as a reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to 8 PM UTC which will convert to 12 PM PST.
Updated the wik also.