retrycf
v0.2.9
Published
retry cloud functions
Downloads
16
Readme
retrycf
retrycf is an npm library that fire Cloud Functions again when it fails.
Install
yarn install retrycf
Usage
export const updateTestOrder = functions.firestore.document(`order/{orderID}`).onUpdate(async event => {
const retryStatus = Retrycf.retryStatus(event.data.data(), event.data.previous.data())
switch (retryStatus) {
case Retrycf.Status.ShouldRetry:
case Retrycf.Status.ShouldNotRetry:
break
case Retrycf.Status.RetryFailed:
throw Error('Retry failed')
default:
break
}
try {
await main(order)
return undefined
} catch (e) {
await Retrycf.setRetry(event.data.ref, event.data.data(), e)
return Promise.reject(e)
}
})