transient

package
v0.0.0-...-678bb0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package transient allows you to tag and retry 'transient' errors (i.e. non-permanent errors which may resolve themselves by trying an operation again). This should be used on errors due to network flake, improperly responsive remote servers (e.g. status 500), unusual timeouts, etc. where there's no concrete knowledge that something is permanently wrong.

Said another way, transient errors appear to resolve themselves with nothing other than the passage of time.

Index

Constants

This section is empty.

Variables

View Source
var Tag = errors.BoolTag{Key: errors.NewTagKey("this error is temporary")}

Tag is used to indicate that an error is transient (i.e. something is temporarially wrong).

Functions

func Only

func Only(next retry.Factory) retry.Factory

Only returns a retry.Iterator that wraps another retry.Iterator. It will fall through to the wrapped Iterator ONLY if an error with the transient.Tag is encountered; otherwise, it will not retry.

Returns nil if f is nil.

Example:

  err := retry.Retry(c, transient.Only(retry.Default), func() error {
    if condition == "red" {
		   // This error isn't transient, so it won't be retried.
		   return errors.New("fatal bad condition")
    } elif condition == "green" {
		   // This isn't an error, so it won't be retried.
		   return nil
    }
    // This will get retried, because it's transient.
    return errors.New("dunno what's wrong", transient.Tag)
  })

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL