Skip to content

Conversation

@fireundubh
Copy link

Change

  • Add persistence to socket count query option

Primary fix

  • Fix trade query complexity error by prioritizing stat filters

Various fixes made along the way

  • Skip callback on errors to prevent incomplete conversions
  • Normalize API currency keys to lowercase for consistent lookups
  • Change sort to alphabetical by league ID for predictable order
  • Add exponential backoff to rate limit retries to prevent infinite loops on 429 errors
  • Add deduplication set when merging fetched item batches
  • Use full URL encoding for leagues instead of simple space replacement
  • Add checks for empty or non-comma-separated x-rate-limit-rules headers
  • Decrement request counts only once per expired timestamp across rules

Test cases

  • Add trade query test suites
  • Add test case for skipping callback on error
  • Add test case for exponential backoff on 429 errors

Recommendations

result = result .. "/" .. realm
end
result = result .. "/" .. league:gsub(" ", "+")
local encodedLeague = league:gsub("[^%w%-%.%_%~]", function(c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use our existing urlEncode function here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason. Just add gsub(" ", "+").

Comment on lines 81 to 91
policies[policyName].retryAfter = os.time() + retryAfter
end
local ruleNames = {}
for match in headers["x-rate-limit-rules"]:gmatch("[^,]+") do
ruleNames[#ruleNames+1] = match:lower()
local rulesHeader = headers["x-rate-limit-rules"]
if rulesHeader and rulesHeader ~= "" then
for match in rulesHeader:gmatch("[^,]+") do
ruleNames[#ruleNames+1] = match:lower()
end
end
for _, ruleName in pairs(ruleNames) do
policies[policyName][ruleName] = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, these should be TAB indented (some more near line 249 too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants