My team at work is in the process of converting some code over to Swift concurrency, and we find ourselves needing a replacement for our
RetryQueue, which leverages
Timers and a
PriorityQueue to retry work items after a specified delay. Something like
DelayQueue from Java seems ideal for this use case. Does anyone have thoughts on how to build something like that in Swift?
My current thinking is to use
AsyncStream to pass work items ready to be retried to consumers and
Task.sleep to delay. I'm getting stuck trying to understand the best way to reset the logic when a new item gets enqueued.