From 282ce8b0e9088a0a215116ce234c0b46f1e0d55f Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 31 Aug 2023 01:29:54 +0200 Subject: [PATCH] Add 429 logging --- src/apiutils.nim | 1 + src/tokens.nim | 2 +- src/types.nim | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/apiutils.nim b/src/apiutils.nim index 37afded..e5b9be2 100644 --- a/src/apiutils.nim +++ b/src/apiutils.nim @@ -103,6 +103,7 @@ template fetchImpl(result, fetchBody) {.dirty.} = setLimited(account, api) raise rateLimitError() elif result.startsWith("429 Too Many Requests"): + echo "[accounts] 429 error, API: ", api, ", account: ", account.id account.apis[api].remaining = 0 # rate limit hit, resets after the 15 minute window raise rateLimitError() diff --git a/src/tokens.nim b/src/tokens.nim index 3628ef6..a4ebe7f 100644 --- a/src/tokens.nim +++ b/src/tokens.nim @@ -109,7 +109,7 @@ proc invalidate*(account: var GuestAccount) = if idx > -1: accountPool.delete(idx) account = nil -proc release*(account: GuestAccount; invalid=false) = +proc release*(account: GuestAccount) = if account.isNil: return dec account.pending diff --git a/src/types.nim b/src/types.nim index 8a7a66e..4cacc4b 100644 --- a/src/types.nim +++ b/src/types.nim @@ -40,8 +40,6 @@ type id*: string oauthToken*: string oauthSecret*: string - # init*: Time - lastUse*: Time pending*: int apis*: Table[Api, RateLimit]