evolution-gaming / cats-helper

Helpers for cats & cats-effect
MIT License
51 stars 17 forks source link

add ResourceRetry #141

Closed dfakhritdinov closed 2 years ago

dfakhritdinov commented 2 years ago

Originally this functionality was implemented in UB but can be useful for other cases as well.

This function is made for 1 particular edge case. Imagine resource which has inside infinite fiber. In case of failure this fiber we must release resource, then wait for small period of time, acquire them and start fiber again. Here is mechanism of retry of amount restart with reset in order to implement failure rate (e.g 1 time no more than per 5 minute) So as if there were 4 falls during the day (1 left), and then for 2 hours everything ok. Amount of possible restart reset again to 5.