Documentation
¶
Overview ¶
Package connectivity reports a server's reachability as transitions rather than as attempts, so a component that retries for as long as it is offline logs when it loses the server and when it gets it back instead of once per retry.
The attempt number is the transition. A caller whose retry loop already counts attempts, as resty's Request.Attempt does, passes the count in to the package-level Lost, Refused and Recovered; one that has no counter of its own uses a Tracker, which keeps it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lost ¶
func Lost(logger logrus.FieldLogger, attempt int, err error)
Lost reports one failed attempt to reach the server. The first attempt is logged at warn level and every one after it at debug, so an outage costs one line however long it lasts.
func Recovered ¶
func Recovered(logger logrus.FieldLogger, attempt int, elapsed time.Duration)
Recovered reports the attempt the server finally answered, naming how many it took and how long since the first one. Callers report only the attempt that ended a run of failures; one that succeeded first time has nothing to say. The wording stays neutral because the run it ends may have been a server that could not answer or one that answered and refused, and only the caller knows which.
func Refused ¶
func Refused(logger logrus.FieldLogger, attempt int, err error)
Refused reports one attempt the server answered by refusing to authorize the device. It reads as a distinct condition from an unreachable server because it is: the server is up, and what has to change is the namespace or the device limit. Levels follow Lost.
Types ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker counts consecutive failures for a caller whose retry loop has no attempt counter to pass in, and reports them through Lost, Refused and Recovered. It holds no lock: a Tracker belongs to the single goroutine running the loop it counts, and two of them covering one server would each report the same outage.
func NewTracker ¶
func NewTracker(logger logrus.FieldLogger) *Tracker
NewTracker returns a Tracker reporting through logger, with no outage in progress.