Conversation
|
Hi @creack, I'm just looking into this PR and it looks good. Thank you!
Can you please describe your use-case a bit more? Do you use redis as the ( |
|
@creack I'm thinking about the pros/cons of passing the context timeout down to the networked-based limit counter(s). Few things to consider:
|
|
I came across this with a related need for context propagation that I can describe in further detail if needed: tracing. If you're using httprate-redis and wrap your Redis client with tracing, the Redis spans aren't attached to the parent. Tracers in Go rely on threading the active span through with https://github.com/redis/go-redis/tree/master/extra/redisotel A context version of Some thoughts on your DDOS question @VojtechVitek:
As a last resort, it's up to the limiter implementation to respect the context, and it can opt to ignore cancelation. In theory you could a context to pass tracing context but ignore the cancelation signal. Or, there's the option to add an option to https://pkg.go.dev/context#WithoutCancel If that were the default behavior it would be truly non-breaking. Tracing would work by default but cancelation could require opt-in. |
As I needed a networked-based limiter with transactions, I had to add the context to httprate.
Initially made the change locally, copy/pasting most of the repo, but might as well push upstream.
It is fully backward compatible.