This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
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.
* Add a retry "decorator" for retrying on errors with an exponential backoff Don't retry during feature tests * Remove pubsub specific files * Move cloud tasks functions out of folder * Remove unnecessary recipe repo logic * Remove pubsub tests * Rename cloud tasks tests folder * Bring back pubsub logic to dlx * Move cloud tasks utils to utils folder * Remove old logger * Remove unused packages * Bump version * Format
- Loading branch information
1 parent
7c9f6f7
commit 44cedc7
Showing
51 changed files
with
426 additions
and
4,253 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import config from "exp-config"; | ||
import { PubSub } from "@google-cloud/pubsub"; | ||
import { logger } from "lu-logger"; | ||
|
||
import { filterUndefinedNullValues } from "./utils/sequences.js"; | ||
|
||
const pubSubClient = new PubSub(); | ||
|
||
export async function sendToDlx(req, errorMessage) { | ||
const message = errorMessage || req.body?.error?.message; | ||
const attributes = Object.fromEntries( | ||
Object.entries(filterUndefinedNullValues(req.attributes)).map(([ key, value ]) => [ key, value.toString() ]) | ||
); | ||
|
||
const pubsubClient = pubSubClient.topic(config.deadLetterTopic); | ||
|
||
try { | ||
await pubsubClient.publishMessage({ | ||
json: { ...req.body, error: { ...req.body?.error, message } }, | ||
attributes: { origin: "cloudTasks", appName: config.appName, ...attributes }, | ||
}); | ||
logger.warning("Sent message to DLX"); | ||
} catch (err) { | ||
logger.error(`Error publishing PubSub message: "${err}". Full message: ${JSON.stringify(message)}`); | ||
throw err; | ||
} | ||
} |
File renamed without changes.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.