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 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.
Click to show internal directories.
Click to hide internal directories.