timeoutcap

package
v1.157.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package timeoutcap reports a caller's timeout_seconds a ceiling replaced (#2210): a connection's call_timeout, which a caller may lower but never raise, or a deployment's export max_timeout. The cap is right, and it is reported so a caller who asked for more can see what was applied instead, and a call stopped by it says which limit that was.

Index

Constants

View Source
const (
	CappedByCallTimeout      = "connection call_timeout"
	CappedByExportMaxTimeout = "export max_timeout"
)

What Cap.CappedBy names: the connection's call_timeout, or the deployment's export max_timeout, replacing a caller's longer timeout_seconds.

View Source
const CallTimeoutOwner = "the connection's call_timeout"

CallTimeoutOwner names the connection's own per-request limit in a timeout sentence.

Variables

This section is empty.

Functions

func Explain

func Explain(msg string, timeout time.Duration, requested int, c Cap) string

Explain is msg with the sentence a timed-out request is reported with in front of it, and msg unchanged when it is not a timeout.

func IsTimeout

func IsTimeout(msg string) bool

IsTimeout reports whether an error message carries a timeout signature: the stable phrases Go's net/http, context and net error types emit. A plain "timeout" substring is not matched, since the word can appear in an upstream's own text.

func Owner

func Owner(requested int, c Cap, msg string) string

Owner names the limit a timed-out request ran under: the connection's call_timeout when the connection's client stopped it (msg carries its "Client.Timeout exceeded") or the caller's value was capped to it, else the caller's own timeout_seconds when one was given.

Types

type Cap

type Cap struct {
	// AppliedSeconds is the timeout the call ran under.
	AppliedSeconds int `json:"timeout_applied_seconds,omitempty"`
	// CappedBy names the ceiling that replaced the caller's value.
	CappedBy string `json:"timeout_capped_by,omitempty"`
	// RequestedSeconds is the caller's own value.
	RequestedSeconds int `json:"timeout_requested_seconds,omitempty"`
}

Cap reports a caller's timeout_seconds that a ceiling replaced. The zero value is no cap, and renders nothing.

func Apply

func Apply(ceiling time.Duration, requested int, by string) (time.Duration, Cap)

Apply is the timeout one call runs under: the caller's requested seconds when they are positive and no longer than ceiling, else the ceiling; by names the ceiling in the report.

func (Cap) Capped

func (c Cap) Capped() bool

Capped reports whether a ceiling replaced the caller's value.

func (Cap) TimedOut

func (c Cap) TimedOut(limit time.Duration, owner string) string

TimedOut is the sentence a call that failed on its deadline is reported with: how long it ran under, which limit that was, and, when a caller's timeout_seconds was capped, that it was. limit is the timeout applied and owner names it ("the connection's call_timeout").

Jump to

Keyboard shortcuts

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