Documentation ¶
Overview ¶
Package rpcutil provides common utility functions for interacting with RPC clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestWithRetries ¶
func RequestWithRetries(ctx context.Context, f func() error, extraTransientCodes ...codes.Code) error
RequestWithRetries calls a function that makes an RPC request. If the function returns an RPC error (possibly wrapped) it will be retried as long as the error matches one of a known set of transient error codes, or one of the error codes listed in `extraTransientCodes`.
Generic network errors that are marked as "temporary" will also be retried.
TODO(olivernewman): Once we're on Go 1.18, use generics to have this function pass through the callback's return value, which will help simplify callsites:
RequestWithRetries[T any](Context, func() (T, error), ...codes.Code) (T, error)
func StatusFromError ¶
StatusFromError returns the GRPC status of the underlying cause of the error if it unwraps to a GRPC error, along with a true boolean. It returns false if the underlying cause of the error is not a GRPC error.
TODO(olivernewman): This is only necessary because `status.FromError()` doesn't unwrap errors. Delete this and use `status.FromError()` directly if and when it learns how to unwrap errors.
Types ¶
This section is empty.