hammer
hammer copied to clipboard
"Delayed" increment of bucket depending
I want to stop failed websocket attempts on my phoenix application, and so the bucket could be called "sockets:failed_conns-#{client_id}", for instance.
In my use case I want to delay incrementing the bucket because I do not yet know when checking whether I want to increment it. I guess I could delay it by using check_rate_inc/{4,5}
by setting the increment integer to 0, when checking initially. I then want to increment and reject the websocket upgrade if the authentication fails, such that a retry will possibly deny.
Can this be done today? There is no function to just increment, is there? :thinking: Meaning that I don't care about the {:allow, _}
or {:deny, _}
at this point
Thanks for bringing this up! I think you're right that there's no current way to just increment the count. I'd be happy to merge a PR that introduced these features. Otherwise, it could be a while before I get around to this.
Thanks again!
Hey!
I didn't notice the reply. GitHub notifications is something I've never paid attention to, for some reason hehe.
I did solve it through just incrementing with 0 when doing my check, working around it that way and then incrementing it properly later.
So it wouldn't be that hard to get a check only in the API instead of doing it my way. Will probably be faster too, since it does not "increment 0" hehe.
I will have a look at it soon :)
closing as seems not needed anymore