0.0.5 • Published 1 year ago
@letry-js/letry v0.0.5
Letry
Let you retry failed process with ease.
TODO
- Basic Retry
- TTL Timeout Support
- Add support to retry the exceeded retry attempts jobs
- Store the exceeded retry attempts jobs data to anywhere, BigQuery abstraction is supported by default for this.
Pre-requisites
- Redis
- Windows Port (https://github.com/tporadowski/redis/releases)
- Others (https://redis.io/download/)
Migrate from pRetry
Using pRetry:
const detail = await pRetry(
async () => await requestCyblocDetail(value.mentor_id),
{
retries: 5,
onFailedAttempt: (error) => {
if (error.retriesLeft === 3) {
withProxyDetail = true;
}
const timeout = 5000;
console.log(
`Retrying in ${
timeout / 1000
} second/s, retry left for cyball performance is ${
error.retriesLeft
}.. reason: ${error}`
);
setTimeout(() => {}, timeout);
},
}
);
Using letry:
const detail = await letry(
"requestCyblocDetailQueue",
value.mentor_id,
requestCyblocDetail,
{
attempts: 5,
backoff: 3000,
onFailedAttempt: (error) => {
if (error.retriesLeft === 3) {
withProxyDetail = true;
}
const timeout = 5000;
console.log(
`Retrying in ${
timeout / 1000
} second/s, retry left for cyball performance is ${
error.retriesLeft
}.. reason: ${error}`
);
setTimeout(() => {}, timeout);
}
}
);