storage: export default shouldRetry function
I've recently stumbled across similar errors to https://github.com/googleapis/google-cloud-go/issues/3735 and applied the proposed fix there - created a new ShouldRetry function for the storage client. However, it seems very odd that I have to copy the code from the default retry function - which also means that any additions/fixes to it will not be reflected in my code automatically. I think it would be nice to have that function exported from the storage package, so it can be used like that:
gcsClient.SetRetry(storage.WithErrorFunc(func(err error) bool {
if storage.DefaultShouldRetry(err) { // this function comes from the storage package
return true
}
return customShouldRetry(err) // my custom retry logic
}))
Thanks for the FR. I think this is a reasonable suggestion given that the updates we made to retry strategy have now been "baked in" for a while, and it will be useful for users to be able to keep up to date with any changes we make to ShouldRetry even while adding custom logic using WithErrorFunc.
I'll make a PR to expose this.