ifaces

package
v0.1.1-rc0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType
	Interface Name
}

Event of a network interface, given the type (added, removed) and the interface name

type EventType

type EventType int

EventType for an interface: added, deleted

const (
	EventAdded EventType = iota
	EventDeleted
)

func (EventType) String

func (e EventType) String() string

type Informer

type Informer interface {
	// Subscribe returns a channel that sends Event instances.
	Subscribe(ctx context.Context) (<-chan Event, error)
}

Informer provides notifications about each network interface that is added or removed from the host. Production implementations: Poller and Watcher.

type Name

type Name string

Name of an interface (e.g. eth0)

type Poller

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

Poller periodically looks for the network interfaces in the system and forwards Event notifications when interfaces are added or deleted.

func NewPoller

func NewPoller(period time.Duration, bufLen int) *Poller

func (*Poller) Subscribe

func (np *Poller) Subscribe(ctx context.Context) (<-chan Event, error)

type Watcher

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

Watcher uses system's netlink to get real-time information events about network interfaces' addition or removal.

func NewWatcher

func NewWatcher(bufLen int) *Watcher

func (*Watcher) Subscribe

func (w *Watcher) Subscribe(ctx context.Context) (<-chan Event, error)

Jump to

Keyboard shortcuts

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