quota apply w/ weight == 0 actually applies 1
- Can all providers support actually processing weight == 0? Do we want to?
- The actual use case was just wanting to retrieve quota statistics. Can this be exposed directly?
Just stumbled across this. I need to know stats without consuming anything. Now, I can apply -1 followed by 1, but that's really ugly. Are there any better workarounds?
EDIT: Actually, sending -1 seems to reset the remaining time, so this doesn't work either.
Hi @freezy,
Sorry you're hitting this. Unfortunately, changing the default behavior could be a breaking change for some clients, so nothing had been decided on this yet. Could you let me know a little bit more about what you're doing? What provider? What quota settings?
Thanks, Scott
Well, I'm about to add a status page for the users so they can see how many hits they have left for the current time window and how long it lasts. So I just need to query the data without touching the stats.
I'm using volos-quota-redis for this. I had a look at the code and saw that when Redis returns -1, it's actually interpreted as "value not added", so adding -2 followed by +2 finally did the trick. Makes it even uglier though.
Another way I could imagine would be querying Redis myself, but then that'll break when you guys change your internal API.
I agree, it's ugly. Unfortunately, I can't offer a better solution at this point.