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
feat(storage): add retry config to the Client and HmacKey operations #5193
Changes from 10 commits
965a217
aca46c1
d7c3ca6
1bf31a9
28834e2
52810ec
d08e24f
407f2ca
9f352b2
f2877c4
a468c69
cfbf45e
a4ffb1b
8daa8d2
67fd783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,8 +89,8 @@ type HMACKey struct { | |
type HMACKeyHandle struct { | ||
projectID string | ||
accessID string | ||
|
||
raw *raw.ProjectsHmacKeysService | ||
retry *retryConfig | ||
raw *raw.ProjectsHmacKeysService | ||
} | ||
|
||
// HMACKeyHandle creates a handle that will be used for HMACKey operations. | ||
|
@@ -100,6 +100,7 @@ func (c *Client) HMACKeyHandle(projectID, accessID string) *HMACKeyHandle { | |
return &HMACKeyHandle{ | ||
projectID: projectID, | ||
accessID: accessID, | ||
retry: c.retry, | ||
raw: raw.NewProjectsHmacKeysService(c.raw), | ||
} | ||
} | ||
|
@@ -126,10 +127,10 @@ func (hkh *HMACKeyHandle) Get(ctx context.Context, opts ...HMACKeyOption) (*HMAC | |
|
||
var metadata *raw.HmacKeyMetadata | ||
var err error | ||
err = runWithRetry(ctx, func() error { | ||
err = run(ctx, func() error { | ||
metadata, err = call.Context(ctx).Do() | ||
return err | ||
}) | ||
}, hkh.retry, true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -156,9 +157,9 @@ func (hkh *HMACKeyHandle) Delete(ctx context.Context, opts ...HMACKeyOption) err | |
} | ||
setClientHeader(delCall.Header()) | ||
|
||
return runWithRetry(ctx, func() error { | ||
return run(ctx, func() error { | ||
return delCall.Context(ctx).Do() | ||
}) | ||
}, hkh.retry, true) | ||
} | ||
|
||
func pbHmacKeyToHMACKey(pb *raw.HmacKey, updatedTimeCanBeNil bool) (*HMACKey, error) { | ||
|
@@ -214,7 +215,12 @@ func (c *Client) CreateHMACKey(ctx context.Context, projectID, serviceAccountEma | |
|
||
setClientHeader(call.Header()) | ||
|
||
hkPb, err := call.Context(ctx).Do() | ||
var hkPb *raw.HmacKey | ||
var err error | ||
err = run(ctx, func() error { | ||
hkPb, err = call.Context(ctx).Do() | ||
return err | ||
}, c.retry, false) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -257,10 +263,10 @@ func (h *HMACKeyHandle) Update(ctx context.Context, au HMACKeyAttrsToUpdate, opt | |
|
||
var metadata *raw.HmacKeyMetadata | ||
var err error | ||
err = runWithRetry(ctx, func() error { | ||
err = run(ctx, func() error { | ||
metadata, err = call.Context(ctx).Do() | ||
return err | ||
}) | ||
}, h.retry, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be conditionally idempotent based on whether the Etag is present in the metadata-- the user may pass it in HMACKeyAttrsToUpdate or not. Are conformance tests catching this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be good now |
||
|
||
if err != nil { | ||
return nil, err | ||
|
@@ -285,6 +291,7 @@ type HMACKeysIterator struct { | |
nextFunc func() error | ||
index int | ||
desc hmacKeyDesc | ||
retry *retryConfig | ||
} | ||
|
||
// ListHMACKeys returns an iterator for listing HMACKeys. | ||
|
@@ -297,6 +304,7 @@ func (c *Client) ListHMACKeys(ctx context.Context, projectID string, opts ...HMA | |
ctx: ctx, | ||
raw: raw.NewProjectsHmacKeysService(c.raw), | ||
projectID: projectID, | ||
retry: c.retry, | ||
} | ||
|
||
for _, opt := range opts { | ||
|
@@ -361,10 +369,10 @@ func (it *HMACKeysIterator) fetch(pageSize int, pageToken string) (token string, | |
|
||
ctx := it.ctx | ||
var resp *raw.HmacKeysMetadata | ||
err = runWithRetry(it.ctx, func() error { | ||
err = run(it.ctx, func() error { | ||
resp, err = call.Context(ctx).Do() | ||
return err | ||
}) | ||
}, it.retry, true) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can inline this declaration