tracer

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: AGPL-3.0 Imports: 7 Imported by: 2

Documentation

Overview

Package tracer provides basic functionalities to monitor a network address until it is online.

Index

Constants

View Source
const (
	StatusRunning = iota
	StatusStopped
)

Possible Tracer status value.

View Source
const (
	ConnOnline = iota
	ConnOffline
)

Possible connection states.

View Source
const (
	TopicConn = "topic_connection"
)

Topic used to publish connectin discovery messgages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	ID  string
	Err error
}

type Pinger

type Pinger interface {
	Addr() net.Addr
	Ping(ctx context.Context) error
	ID() string
}

Pinger wraps the basic Ping function.

type PubSub

type PubSub interface {
	Sub(cmd *pubsub.Command) (pubsub.CancelFunc, error)
	Pub(message interface{}, topic string)
}

PubSub describes the required functionalities of a publication/subscription object.

type Tracer

type Tracer struct {
	PubSub

	RefreshRate time.Duration

	sync.Mutex
	// contains filtered or unexported fields
}

Tracer can monitor remote interfaces until they're up.

func New

func New() *Tracer

New returns a new instance of Tracer.

func (*Tracer) Close

func (t *Tracer) Close()

Close makes the tracer pass from status running to status stopped.

func (*Tracer) Run

func (t *Tracer) Run() error

Run makes the tracer listen for refresh calls and perform ping operations on each connection that is labeled with pending. Quits immediately when Close is called, runs in its own gorountine.

func (*Tracer) Status

func (t *Tracer) Status() int

Status returns the status of tracer.

func (*Tracer) Trace

func (t *Tracer) Trace(p Pinger) error

Trace makes the tracer keep track of the entity at addr.

func (*Tracer) Untrace

func (t *Tracer) Untrace(id string)

Untrace removes the entity stored with id from the monitored entities.

Jump to

Keyboard shortcuts

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