staticweb-io/rate-limit

custom response handlers take instants, not durations?

rgm opened this issue · 2 comments

rgm commented

I hit a 500 in production recently when a rate limit was tripped. I can work around it with a custom response builder.

I'm confused about io.staticweb.rate-limit.responses/add-retry-after-header: when I went logging to debug, it seems retry-after here is a java.time.Instant, not a java.time.Duration.

rgm@f764f8e

I can turn this into a PR if it's helpful and I'm actually correct.

Thank you. That patch is very helpful.

That fix works, but the docs and tests assume that a Duration will be passed to add-retry-after-header. I think it is better to do the Instant to Duration conversion in read-quota-state, which I've done in a3921da. Does latest master fix the issue for you?

rgm commented

Sorry, John, took me a bit to circle back to this.

Yes, a3921da works great for me. Your way is (unsurprisingly) better, so I'll close this out. Thank very much.