@@ -19,15 +19,9 @@ Google Cloud Storage stores data in named objects, which are grouped into bucket
19
19
More information about Google Cloud Storage is available at
20
20
https://cloud.google.com/storage/docs.
21
21
22
- See https://godoc.org /cloud.google.com/go for authentication, timeouts,
22
+ See https://pkg.go.dev /cloud.google.com/go for authentication, timeouts,
23
23
connection pooling and similar aspects of this package.
24
24
25
- All of the methods of this package use exponential backoff to retry calls that fail
26
- with certain errors, as described in
27
- https://cloud.google.com/storage/docs/exponential-backoff. Retrying continues
28
- indefinitely unless the controlling context is canceled or the client is closed. See
29
- context.WithTimeout and context.WithCancel.
30
-
31
25
32
26
Creating a Client
33
27
@@ -246,12 +240,52 @@ as the documentation of GenerateSignedPostPolicyV4.
246
240
247
241
Errors
248
242
249
- Errors returned by this client are often of the type [`googleapi.Error`](https://godoc.org/google.golang.org/api/googleapi#Error).
250
- These errors can be introspected for more information by using `errors.As` with the richer `googleapi.Error` type. For example:
243
+ Errors returned by this client are often of the type googleapi.Error.
244
+ These errors can be introspected for more information by using errors.As
245
+ with the richer googleapi.Error type. For example:
251
246
252
247
var e *googleapi.Error
253
248
if ok := errors.As(err, &e); ok {
254
249
if e.Code == 409 { ... }
255
250
}
251
+
252
+ See https://pkg.go.dev/google.golang.org/api/googleapi#Error for more information.
253
+
254
+ Retrying failed requests
255
+
256
+ Methods of this package may use exponential backoff to retry calls
257
+ that fail with transient errors. Retrying continues indefinitely unless the
258
+ controlling context is canceled, the client is closed, or a non-transient error
259
+ is received. See context.WithTimeout and context.WithCancel.
260
+
261
+ Retry strategy in this library follows best practices for Cloud Storage. By
262
+ default, only idempotent operations are retried, exponential backoff with jitter
263
+ is employed, and only transient network errors and response codes defined as
264
+ transient by the service and will be retried. See
265
+ https://cloud.google.com/storage/docs/retry-strategy for more information.
266
+
267
+ Users can configure non-default retry behavior for a particular operation (using
268
+ BucketHandle.Retryer and ObjectHandle.Retryer) or for all calls made by a
269
+ client (using Client.SetRetry). For example:
270
+
271
+ o := client.Bucket(bucket).Object(object).Retryer(
272
+ // Use WithBackoff to change the timing of the exponential backoff.
273
+ storage.WithBackoff(gax.Backoff{
274
+ Initial: 2 * time.Second,
275
+ }),
276
+ // Use WithPolicy to configure the idempotency policy. RetryAlways will
277
+ // retry the operation even if it is non-idempotent.
278
+ storage.WithPolicy(storage.RetryAlways),
279
+ )
280
+
281
+ // Use context timeouts to set an overall deadline on the call, including all
282
+ // potential retries.
283
+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
284
+ defer cancel()
285
+
286
+ // Delete an object using the specified strategy and timeout.
287
+ if err := o.Delete(ctx); err != nil {
288
+ // Handle err.
289
+ }
256
290
*/
257
291
package storage // import "cloud.google.com/go/storage"
0 commit comments