connectionliveness

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 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 connectionliveness judges a connection dead only after a full timeout without accepted inbound frames. One delayed reply, such as an acknowledgement queued behind content, is never evidence of loss, so liveness does not depend on any single round trip or on WebSocket Ping/Pong support by the host.

Index

Constants

This section is empty.

Variables

View Source
var ErrSilent = errors.New("connection liveness: no accepted inbound frame within timeout")

Functions

func Watch

func Watch(ctx context.Context, m *Monitor, timeout time.Duration) (time.Duration, error)

Watch blocks until the connection has been silent for timeout and returns that silence with ErrSilent, or returns the context's error first. Each wake re-reads the evidence, so traffic defers expiry without resetting a timer per frame.

Types

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor tracks the newest accepted inbound frame of one connection. Readers observe while a separate owner evaluates silence, so the instant is atomic.

func NewMonitor

func NewMonitor(now time.Time) *Monitor

NewMonitor starts the silence clock at now, so a connection that never delivers a frame still fails after one timeout.

func (*Monitor) Observe

func (m *Monitor) Observe(now time.Time)

Observe records an inbound frame the connection's protocol accepted. Frames that close the connection as violations are not evidence and need no call.

func (*Monitor) Silence

func (m *Monitor) Silence(now time.Time) time.Duration

Silence reports how long the connection has gone without accepted inbound frames.

Jump to

Keyboard shortcuts

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