Back to godoc.org

Package transient

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

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

Variables

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).

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)
  })
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier