softwaremill/retry

How to do graceful shutdown?

kkalavantavanich opened this issue · 5 comments

How can I do graceful shutdown using this library? Say I have some code that is doing retry on some HTTP call. Then the application starts shutting down. Can I somehow register that this should be gracefully shut down?

adamw commented

I don't think such functionality would fit this library. What you are looking for is probably sth like Resource or Using, or Future.onComplete

Do you mean as a wrapper around retry or retry as a wrapper around those mechanisms?

adamw commented

a wrapper around retry. Something like allocateResource.flatMap(r => retry(useResource(r)).onComplete(releaseResource(r)))

adamw commented

assuming we're working with Futures

I see. That sounds reasonable. Thanks 🙏 .