datastore: Index | Examples | Files

package rpcretry

import ""

Package rpcretry automatically retries when some RPCs end in error. RPC sometimes fails rarely and this may be able to recover simply by retrying.

Non idempotency operations (Commit, Rollback, and Next) are not automatically retried.

By default, it retries up to 3 times. First wait 100 milliseconds, then wait exponentially back off. This value can be changed by option.


ctx := context.Background()
client, err := clouddatastore.FromContext(ctx)
if err != nil {
defer client.Close()
defer testutils.CleanUpAllEntities(ctx, client)

mw := rpcretry.New(
    // rpcretry.WithMaxDoublings(2),



Package Files

doc.go option.go rpcretry.go

func New Uses

func New(opts ...RetryOption) datastore.Middleware

New automatically RPC retry middleware creates & returns.

type RetryOption Uses

type RetryOption interface {

A RetryOption is an retry option for a retry middleware.

func WithLogf Uses

func WithLogf(logf func(ctx context.Context, format string, args ...interface{})) RetryOption

WithLogf creates a ClientOption that uses the specified logger.

Deprecated: use WithLogger instead.

func WithLogger Uses

func WithLogger(logf func(ctx context.Context, format string, args ...interface{})) RetryOption

WithLogger creates a ClientOption that uses the specified logger.

func WithMaxBackoffDuration Uses

func WithMaxBackoffDuration(d time.Duration) RetryOption

WithMaxBackoffDuration specified maximum duratiuon of retry backoff.

func WithMaxDoublings Uses

func WithMaxDoublings(maxDoublings int) RetryOption

WithMaxDoublings specifies how many times the waiting time should be doubled.

func WithMinBackoffDuration Uses

func WithMinBackoffDuration(d time.Duration) RetryOption

WithMinBackoffDuration specified minimal duration of retry backoff.

func WithRetryLimit Uses

func WithRetryLimit(limit int) RetryOption

WithRetryLimit provides retry limit when RPC failed.

Package rpcretry imports 6 packages (graph) and is imported by 2 packages. Updated 2019-08-08. Refresh now. Tools for package owners.