keepaliver

package
v0.0.0-...-7085b38 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeepAliver

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

A KeepAliver sends KeepAlive packets to the client and notifies when the client doesn't respond in time.

func New

func New(interval time.Duration, w io.Writer) KeepAliver

New creates a new KeepAliver.

func NewForTesting

func NewForTesting(sendInterval, mustRespondIn time.Duration, w io.Writer, rr rand.Source) KeepAliver

NewForTesting creates a new KeepAliver for testing. Notably, it allows providing a source of random data for predictability.

func (*KeepAliver) Notifier

func (p *KeepAliver) Notifier() <-chan struct{}

Notifier returns a channel that is sent a value when the client doesn't respond in time.

func (*KeepAliver) Receive

func (p *KeepAliver) Receive(id int64)

Receive marks a keepalive ID as received.

func (*KeepAliver) StartPinging

func (k *KeepAliver) StartPinging(ctx context.Context, logger *log.Logger)

StartPinging repeatedly sends keepalives until its context is cancelled. This function is blocking and should be run within a goroutine.

Jump to

Keyboard shortcuts

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