volos icon indicating copy to clipboard operation
volos copied to clipboard

quota apply w/ weight == 0 actually applies 1

Open theganyo opened this issue 11 years ago • 4 comments

  1. Can all providers support actually processing weight == 0? Do we want to?
  2. The actual use case was just wanting to retrieve quota statistics. Can this be exposed directly?

theganyo avatar Aug 23 '14 23:08 theganyo

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.

freezy avatar Oct 25 '15 12:10 freezy

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

theganyo avatar Oct 26 '15 20:10 theganyo

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.

freezy avatar Oct 26 '15 21:10 freezy

I agree, it's ugly. Unfortunately, I can't offer a better solution at this point.

theganyo avatar Nov 05 '15 00:11 theganyo