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

Re-sign request on retry #216

Merged
merged 6 commits into from
May 9, 2024
Merged

Re-sign request on retry #216

merged 6 commits into from
May 9, 2024

Conversation

mgwoj
Copy link
Contributor

@mgwoj mgwoj commented Mar 8, 2024

In our case we need to re-sign request before initiating retry operation. To achieve that we have added a new handler PrepareRetry which can be used for this purpose, however the signature and the name is as generic as possible.

@mgwoj mgwoj requested review from a team, dekimsey and emilymianeil March 8, 2024 15:43
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 8, 2024

CLA assistant check
All committers have signed the CLA.

@mgwoj
Copy link
Contributor Author

mgwoj commented Mar 12, 2024

Hello @dekimsey and @emilymianeil , do you have any timeline when this could be reviewed and merged?

wzagrajcz pushed a commit to akamai/terraform-provider-akamai that referenced this pull request Mar 26, 2024
wzagrajcz added a commit to akamai/terraform-provider-akamai that referenced this pull request Mar 26, 2024
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thank you @mgwoj for this PR! This seems like a reasonable addition and I like the implementation. My only suggestion would be to accommodate a default nil value for Client.PrepareRetry - this would offer maximum compatibility for consumers who might be constructing their own Client.

client.go Outdated
@@ -435,6 +441,7 @@ func NewClient() *Client {
RetryMax: defaultRetryMax,
CheckRetry: DefaultRetryPolicy,
Backoff: DefaultBackoff,
PrepareRetry: DefaultPrepareRetry,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this default function does nothing, can we leave the default as nil here?

client.go Outdated
Comment on lines 561 to 566
// DefaultPrepareRetry is performing noop during prepare retry
func DefaultPrepareRetry(_ *http.Request) error {
// noop
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed if we accommodate a nil value for client.PrepareRetry

client.go Outdated
Comment on lines 745 to 748
if err := c.PrepareRetry(req.Request); err != nil {
prepareErr = err
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the above, can we conditionally attempt this if the function is non-nil?

Suggested change
if err := c.PrepareRetry(req.Request); err != nil {
prepareErr = err
break
}
if c.PrepareRetry != nil {
if err := c.PrepareRetry(req.Request); err != nil {
prepareErr = err
break
}
}

@mgwoj
Copy link
Contributor Author

mgwoj commented Apr 26, 2024

Thank you for reviewing and accepting the proposed solution for prepare retry. I have applied your suggestions.

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thanks @mgwoj, this LGTM! 👍

@manicminer manicminer added this to the v0.7.6 milestone May 8, 2024
@manicminer manicminer merged commit ca91556 into hashicorp:main May 9, 2024
1 check passed
manicminer added a commit that referenced this pull request May 9, 2024
manicminer added a commit that referenced this pull request May 9, 2024
identw pushed a commit to identw/terraform-provider-akamai that referenced this pull request Nov 8, 2024
identw pushed a commit to identw/terraform-provider-akamai that referenced this pull request Nov 8, 2024
identw pushed a commit to identw/terraform-provider-akamai that referenced this pull request Nov 8, 2024
identw pushed a commit to identw/terraform-provider-akamai that referenced this pull request Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants