vapor / queues

A queue system for Vapor.
MIT License
169 stars 41 forks source link

Retry delay #79

Closed jnordberg closed 3 years ago

jnordberg commented 4 years ago

Would be nice to be able to be able to specify a delay between retries.

Maybe something like

protocol Job {
    func nextRetry(attempt: Int) -> Date
}
extension Job {
    func nextRetry(attempt: Int) -> Date { return Date() }
}

That would allow you to implement exponential backoff etc

jdmcd commented 4 years ago

Agreed, this is a good idea. Unfortunately this would be a break change (unless we can find a different way to accomplish it) so would need to wait for Queues v2.

jnordberg commented 4 years ago

Wouldn't the default implementation in the protocol make it backwards compatible? 🤔

jdmcd commented 4 years ago

@tanner0101 would need to weigh in here but I'm pretty sure any public protocol addition regardless of default implementation is semvar major

tanner0101 commented 4 years ago

@jdmcd if it has a default impl that's fine for semver minor. (By Vapor's semver rules at least--other projects might be more strict)

jdmcd commented 4 years ago

Oh fantastic! In this case then I think it'd be a great addition.

Andrewangeta commented 3 years ago

I just had a dream about this kinda feature for queues haha. I think it'd be super helpful as well like an exponential back off sort of retry. Similar to how stripe retries failed webhooks

jdmcd commented 3 years ago

Totally agreed, I think this would be great! Unfortunately I don't have a ton of bandwidth to implement it myself but if anyone else wants to I'm more than happy to provide guidance + reviews!

kacperk commented 3 years ago

@jdmcd I think you can close this issue now