multiping

package module
v0.0.0-...-404304f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 10 Imported by: 0

README

made-with-Go Build Tests GitHub release GitHub license

go-multiping

Ping library, that can ping and process multipple nodes at once

The motivation for this multi-ping fork

There are quite a few Go pinger, but all of them have issues:

Also need to mention that all these pingers are periodic pingers, they try to mimmic shell ping command. They run in internal loop, cancel that loop after timeout. They can be used, but you have to adjust your code to their style. Instead I wanted a pinger, that can ping multipple hosts at a time and be robust. I don't think its a problem for ping user to run it in a loop and don't want any hidden logic.

So this ping is loosely based on above mentioned projects. It can ping multiple clients. And is cholesterol free.

Note about concurency

The main package MultiPing has internal lock and can be reused in multiple threads with different PingData.

The PingData however is not tread safe. This mean that during Ping its content can change and thus the caller is responsible for locking.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiPing

type MultiPing struct {
	// Locks MultiPing to protect internal members
	sync.RWMutex

	// Timeout specifies a timeout before ping exits, regardless of how many
	// packets have been received. Default is 1s.
	Timeout time.Duration

	// Tracker: Used to uniquely identify packet when non-priviledged
	Tracker int64
	// contains filtered or unexported fields
}

func New

func New(privileged bool) (*MultiPing, error)

func (*MultiPing) Ping

func (mp *MultiPing) Ping(data *pingdata.PingData)

Ping is blocking function and runs for mp.Timeout time and pings all hosts in data

type PingClient

type PingClient interface {
	PingProcess(pr *pingdata.PingData)
}

Unified interface to process ping data

Directories

Path Synopsis
This file code is based on https://github.com/go-ping/ping
This file code is based on https://github.com/go-ping/ping

Jump to

Keyboard shortcuts

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