2021-09-11 21:49:46 +00:00
|
|
|
package healthcheck
|
|
|
|
|
|
|
|
|
|
import "github.com/go-ping/ping"
|
|
|
|
|
|
|
|
|
|
//go:generate mockgen -destination=pinger_mock_test.go -package healthcheck . Pinger
|
|
|
|
|
|
|
|
|
|
type Pinger interface {
|
|
|
|
|
Run() error
|
|
|
|
|
Stop()
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-11 22:22:55 +00:00
|
|
|
func newPinger(addrToPing string) (pinger *ping.Pinger) {
|
2021-09-11 21:49:46 +00:00
|
|
|
const count = 1
|
|
|
|
|
pinger = ping.New(addrToPing)
|
|
|
|
|
pinger.Count = count
|
2021-09-11 22:22:55 +00:00
|
|
|
pinger.SetPrivileged(true) // see https://github.com/go-ping/ping#linux
|
2021-09-11 21:49:46 +00:00
|
|
|
return pinger
|
|
|
|
|
}
|