avivbiton / BlizzardApiReader

.Net Core library to handle Blizzard public APIs
MIT License
35 stars 36 forks source link

Api key specific to RateLimiter #34

Open linahanner opened 5 years ago

linahanner commented 5 years ago

As has been mentioned in issue #10 the rate limitation is specific to each key. Right now the key being used is determined by the key within the ApiConfiguration and the rates are counted regardless of which key is being used.

This prevents the user of the library from using multiple api keys for the same ApiReader and would need to create multiple instances of the ApiReader for each key and write their own logic in case a key has reached its limit.

A suggestion is to store each api key inside of the rate limiters, instead of inside the ApiConfiguration. That way we can easily apply the logic of the rate limiters for each key and allow for things, such as, being able to have multiple api keys and once one key has reached its limits it will automatically go to the next key in the list.

This would include logic such as...

Does this sound like a good idea, @avivbiton?

avivbiton commented 5 years ago

The intened behind the TimeRateLimiter is that it is useful when you want to set a custom limit to your key rather then the amout set by Blizzard. This is useful when you have multiple clients running with the same key and don't want one client to drain all the requests leaving all the other clients empty.
Currently on mobile i will go a bit more in depth when i get home

avivbiton commented 5 years ago

IRateLimiter Interface is there so we can easily add new types of limiters, as well allow easy creation of custom rate limiter outside the library.
TimeRateLimiter is just the basic one I made and wanted to allow other contributors to work on more therefore I didn't expend much on that.
By that, it means you can easily create a new type of IRateLimiter that can handle multiple keys

I do like the idea of allowing multiple keys to be added to the ApiReader (I feel like it will fit better there) and then allow some options on how they rotate / used.
Also, I kinda want to create some sort of sketch on about the different abstraction level of the library and maybe make some changes, I will do that soon and open an issue about it .

avivbiton commented 5 years ago

On hold until the migration to the new portal is done