model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package model holds the attempt arithmetic and the report types.

Index

Constants

This section is empty.

Variables

Functions

func Flag

func Flag(f *Finding)

Flag adds the named problems to a finding. Call after Compute.

func SortFindings

func SortFindings(fs []*Finding)

SortFindings orders by attempts (unbounded first), then anchor.

Types

type Attempts

type Attempts struct {
	Kind       Kind
	N          int           // Exact, or the largest known candidate for Unknown
	Deadline   time.Duration // TimeBounded
	Ref        string        // Unknown: what it depends on, e.g. "tools.MediaProviderEntry.MaxRetries"
	ConfigKey  string        // Unknown: struct tag key when the field is loaded from config, e.g. "max_retries"
	Candidates []int         // Unknown: constants we did see stored
	Note       string        // e.g. "conditional-on-context"
}

Attempts is how many times one layer sends a request, including the first try.

func MaxOf

func MaxOf(a, b Attempts) Attempts

MaxOf picks the larger of two alternatives (e.g. two possible call targets).

func Mul

func Mul(a, b Attempts) Attempts

Mul multiplies two layers. Unbounded or TimeBounded anywhere makes the product Unbounded. Unknown stays Unknown and carries the known part.

func N

func N(n int) Attempts

func One

func One() Attempts

func TB

func TB(d time.Duration) Attempts

func Unb

func Unb() Attempts

func (Attempts) Resolve

func (a Attempts) Resolve(values map[string]int, plusOne bool) Attempts

Resolve replaces an Unknown with a value from a --values map, looked up by config key first and then by Ref.

func (Attempts) String

func (a Attempts) String() string

func (Attempts) Upper

func (a Attempts) Upper() (n int, ok bool)

Upper returns the number used for thresholds. Unknown counts as its largest known candidate (or 1), so the CI gate needs --fail-on-unresolved for those. ok is false for Unbounded and TimeBounded.

type Class

type Class string

Failure classes a fault can fall into. Code layers retry on any of them.

const (
	ClassConnect Class = "connect"   // connection refused / reset before response
	Class503     Class = "5xx-503"   // upstream answered 503
	Class5xx     Class = "5xx-other" // upstream answered another 5xx
	ClassTimeout Class = "timeout"   // upstream too slow
)

type Finding

type Finding struct {
	Anchor     string           `json:"anchor"`   // where the outermost layer is
	Outbound   string           `json:"outbound"` // the call that hits the network
	OutboundAt string           `json:"outbound_at"`
	Host       string           `json:"host,omitempty"`
	HostUnres  bool             `json:"host_unresolved,omitempty"`
	Layers     []Layer          `json:"layers"` // outermost first
	Product    map[Class]string `json:"attempts_by_class,omitempty"`
	Total      string           `json:"attempts"` // max over classes
	TotalN     int              `json:"attempts_n"`
	Bounded    bool             `json:"bounded"`
	Unresolved bool             `json:"unresolved,omitempty"`
	Path       []string         `json:"path"`
	Flags      []string         `json:"flags,omitempty"`
	Assume     []string         `json:"assumptions,omitempty"`
	// contains filtered or unexported fields
}

Finding is one outermost retry region paired with one outbound call site.

func (*Finding) Compute

func (f *Finding) Compute()

Compute fills Product/Total from Layers.

func (*Finding) ProductFor

func (f *Finding) ProductFor(c Class) Attempts

ProductFor returns the computed product for one class.

type Kind

type Kind int

Kind of an attempt count.

const (
	Exact       Kind = iota // a known number of attempts
	Unbounded               // no bound found
	TimeBounded             // bounded only by a deadline
	Unknown                 // depends on a value we could not resolve
)

type Layer

type Layer struct {
	Kind     LayerKind `json:"kind"`
	Attempts Attempts  `json:"-"`
	Count    string    `json:"attempts"`
	// RetryOn nil means "any error" (code layers).
	RetryOn    map[Class]bool `json:"-"`
	RetryOnStr string         `json:"retry_on,omitempty"`
	PerTry     time.Duration  `json:"per_try_timeout,omitempty"`
	Timeout    time.Duration  `json:"timeout,omitempty"`
	Backoff    bool           `json:"backoff"`
	Jitter     bool           `json:"jitter"`
	IgnoresCtx bool           `json:"ignores_context,omitempty"`
	Source     string         `json:"source"`         // declared | library-default | mesh-default (assumed)
	Where      string         `json:"where"`          // file:line or config resource
	Loop       string         `json:"loop,omitempty"` // wrapper layer: where its retry loop is
	Func       string         `json:"func,omitempty"`
}

Layer is one retrying component on the way from a caller to the wire.

func (Layer) Retries

func (l Layer) Retries(c Class) bool

Retries reports whether this layer retries the class.

type LayerKind

type LayerKind string

LayerKind says where a retry layer lives.

const (
	LayerCodeLoop    LayerKind = "code-loop"    // hand-rolled loop in a function
	LayerCodeWrapper LayerKind = "code-wrapper" // a retry helper called with a func argument
	LayerLibrary     LayerKind = "library"      // e.g. go-retryablehttp, aws-sdk-go-v2
	LayerMesh        LayerKind = "istio"        // caller sidecar, from a VirtualService or the mesh default
	LayerEnvoy       LayerKind = "envoy"        // envoy static route retry_policy
)

Jump to

Keyboard shortcuts

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