Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enforcing aws client requests which will retry non-200 requests #75

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion nimutils/awsclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,10 @@ proc request*(client: var AwsClient, params: Table, headers: HttpHeaders = newHt
client.httpClient.headers.table, client.scope)
client.httpClient.headers.add("Authorization", auth)

return client.httpClient.safeRequest(url, action, payload, headers=headers)
return client.httpClient.safeRequest(
url,
action,
payload,
headers=headers,
only2xx=true,
)
5 changes: 1 addition & 4 deletions nimutils/sinks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ proc s3SinkOut(msg: string, cfg: SinkConfig, t: Topic, ignored: StringTable) =
newPath = joinPath(state.objPath, newTail)
response = client.put_object(state.bucket, newPath, msg)

if not response.code.is2xx():
raise newException(ValueError, response.status & ": " & response.body())
else:
cfg.iolog(t, "Post to: " & newPath & "; response = " & response.status)
cfg.iolog(t, "Post to: " & newPath & "; response = " & response.status)

proc httpHeaders(cfg: SinkConfig): HttpHeaders =
var
Expand Down
2 changes: 0 additions & 2 deletions nimutils/stsclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ proc getCallerIdentity*(self: var StsClient): StsCallerIdentity =
("Content-Type", "application/x-www-form-urlencoded"),
("Accept", "application/json"),
]))
if res.code != Http200:
raise newException(ValueError, res.status)
let
jsonResponse = parseJson(res.body())
identity = jsonResponse["GetCallerIdentityResponse"]["GetCallerIdentityResult"]
Expand Down