idle

package
v0.0.0-...-09b1dbd Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimedOut = errors.New("timed out due to no activity")

Functions

This section is empty.

Types

type IdleTimer

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

IdleTimer is a dead-mans switch to detect inactivity. Create with New.

func New

func New(d time.Duration) *IdleTimer

New creates an IdleTimer that will return errors if the there is no activity seen for the given duration.

func (*IdleTimer) Run

func (t *IdleTimer) Run(ctx context.Context) error

Run runs until the context is cancelled or no-one calls SetActive for more than the timer's duration. Always returns an error, either the context's or ErrTimedOut.

func (*IdleTimer) SetActive

func (t *IdleTimer) SetActive()

SetActive marks this timer as still active.

Jump to

Keyboard shortcuts

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