I'm building an application that uses the Riot Games API. My single API key has rate-limits for each subdomain. I plan on using this enum class. Would it work if i attached a Bucket to that enum instance to hold tokens for each request, or does Enum instances get reset or something similar by garbage collector for example? Or would it be better to have another class with a HashMap with the enum as key, and bucket as value?
I wrote the question and read my code an extra time, and realized multiple enums would share the "regionUrl" endpoint, which further complicates how i would do this and it leaves me a but clueless.
Any help and wisdom is appreciated ๐
Heres my code:
public enum LeagueOfLegendsEndpoint {
EUN1("europe"), EUW1("europe"), TR1("europe"), RU("europe"),
BR1("americas"), LA1("americas"), LA2("americas"), NA1("americas"),
JP1("asia"), KR("asia"),
OC1("sea"), PH2("sea"), SG2("sea"), TH2("sea"), TW2("sea"), VN2("sea");
@Getter private final String serverUrl;
@Getter private final String regionUrl;
LeagueOfLegendsEndpoint(String region) {
this.serverUrl = name().toLowerCase() + ".api.riotgames.com";
this.regionUrl = region + ".api.riotgames.com";
}
}```