connectivity

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

connectivity

Go Report Card Documentation

See example usage in ./examples.

Documentation

Overview

Package connectivity provides primitives for recording one's internet connectivity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind represents a span kind.

const (
	Offline Kind = iota
	Online
)

Kinds of connectivity spans.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a recorder instance.

func WithProbe

func WithProbe(probe Probe) Option

WithProbe configuress the used connectivity probe.

func WithProbeInterval

func WithProbeInterval(d time.Duration) Option

WithProbeInterval configures the duration between consecutive connectivity probes.

func WithProbeTimeout

func WithProbeTimeout(d time.Duration) Option

WithProbeTimeout configures the timeout for individual connectivity probes.

type Probe

type Probe func(context.Context) error

Probe represents a connectivity probe.

type Recorder

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

Recorder records one's connectivity.

func NewRecorder

func NewRecorder(opts ...Option) *Recorder

NewRecorder returns new connectivity recorder.

func (*Recorder) Spans

func (c *Recorder) Spans() []Span

Spans returns all recorded connectivity spans.

func (*Recorder) Stop

func (c *Recorder) Stop()

Stop stops recording.

type Span

type Span struct {
	Kind      Kind // Offline or Online span.
	StartTime time.Time
	EndTime   time.Time
}

Span describes one's connectivity for a time period.

func (*Span) Duration

func (s *Span) Duration() time.Duration

Duration returns the duration of the span.

Directories

Path Synopsis
examples
cmd

Jump to

Keyboard shortcuts

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