Skip to content

r-cohen/watchdog-channel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

watchdog-channel

A simple watchdog timer based on golang channels

Installation

go get github.com/r-cohen/watchdog-channel

Usage

// kicks at interval on the GetKickChannel()
wd := watchdog.NewWatchdog(time.Second * 3)
go func(w *watchdog.Watchdog) {
	i := 0
	for {
		select {
		case <-w.GetKickChannel():
			fmt.Println("kick!")
			i++
			if i == 3 {
				// stop the watchdog permanently
				w.Stop()
				return
			}
		}
	}
}(wd)

Reset the watchdog timer:

w.Reset()

Online example

Go Playground

About

A simple watchdog based on golang channels

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages