Hello,
I have a scenario where an executed cloud script has to post a result to a webhook. In some cases, the post may fail, whether because the url is incorrect or the server hosting the webhook api is temporarily down. Naturally, I'd like to be able to queue this failed post somewhere to try again later (perhaps with a scheduled task). Thus, I tested the following code:
var failedWebhookQueues = []; handlers.syncTransactions = function (args, context) { let hook = context.playStreamEvent.Hook; if(!hook) { log.error("No response url."); } else { let content = {TxnId : "TX10222", Status: "Success"}; let hookResult = http.request(hook, "post", JSON.stringify(content) , "application/json", {owo : "owo", whats : "this"}); if(!hookResult.includes("200")) { failedWebhookQueues.push(content); } } return {failedWebhookQueues, hook}; }
After executing this a few times with a wrong webhook, I received this in the function result:
This clearly shows that the array failedWebhookQueues is storing data between cloudscript executions.
My questions are the following:
What is the reliability of this object? Can I expect it to persist between revisions? Could it suddenly be wiped out of memory for no reason? What are the storage limits when using objects like this?
In addition to these questions, you may provide any clarifications deemed necessary.
Could you recommend an alternative storage method that doesn't rely on 3rd party storage?