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

DiscoverNewWarehouseTables #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wumadeline
Copy link
Collaborator

Implements a client method for Discover new data warehouse tables. As part of this PR, we add some additional (shared) error handling logic. If the request returns a 429 status code, we attempt to parse the response header for the Retry-After value, which represents how long the user should wait before reissuing a request.

Copy link
Collaborator

@squareJake squareJake left a comment

Choose a reason for hiding this comment

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

Looks great! Were you able to test this? I don't have the an admin role for any organization so wasn't able to confirm things locally

@@ -107,6 +107,10 @@ func (c *Client) apiCallWithBody(endpoint string, method string, jsonParams stri
}

if resp.StatusCode != 200 {
// Parse header for retry time
if retryAfter, ok := resp.Header["Retry-After"]; resp.StatusCode == 429 && ok {
return nil, fmt.Errorf("Too many requests, retry after: %s seconds", retryAfter)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The anomalo API docs don't say - but hopefully this follows the convention for Retry-After of using seconds? I'm kind of surprised that's the default unit actually - seems pretty coarse for what is probably often a short term issue.

It might also be nice to expose the number of seconds to wait in a custom error (instead of just the message string) so callers can actually wait that long - but not necessary for this PR

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