luci: Index | Files

package transient

import ""

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.


Package Files



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 Uses

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.


  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)

Package transient imports 4 packages (graph) and is imported by 192 packages. Updated 2021-01-20. Refresh now. Tools for package owners.