node

package
v0.0.0-...-72c7af3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RegisterAction   = iota
	DeregisterAction = iota
)

Modes of a node being registered

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Payload      []byte // max 256 bytes
	SrcIP        net.IP
	SendInterval time.Duration
	Action       int
	Heartbeat    *time.Timer
	Mutex        sync.Mutex
	// contains filtered or unexported fields
}

Node represents a machine registered with Disco

func DecodeNode

func DecodeNode(b []byte) (*Node, error)

DecodeNode decodes the bytes and returns a *Node struct

func (*Node) Done

func (n *Node) Done() <-chan struct{}

Done returns a channel that can be used to wait till Multicast is stopped

func (*Node) Encode

func (n *Node) Encode() []byte

Encode will convert a Node to a byte slice Checksum - 4 bytes IPv4 value - 4 bytes IPv6 value - 16 bytes Action value - 1 byte Send Interval - 8 bytes Payload (unknown length)

func (*Node) Equal

func (n *Node) Equal(b *Node) bool

Equal compares nodes

func (*Node) IPv4

func (n *Node) IPv4() net.IP

IPv4 getter for ipv4Address

func (*Node) IPv6

func (n *Node) IPv6() net.IP

IPv6 getter for ipv6Address

func (*Node) KeepRegistered

func (n *Node) KeepRegistered()

KeepRegistered sends an anonymous struct{} to registeredChan to indicate the node should stay registered

func (*Node) Multicast

func (n *Node) Multicast(ctx context.Context, multicastAddress string) <-chan error

Multicast start the multicast ping

func (*Node) RegisterCh

func (n *Node) RegisterCh() <-chan struct{}

RegisterCh returns a channel to know if the node should stay registered

func (*Node) Stop

func (n *Node) Stop()

Stop multicasting and ticking

func (*Node) String

func (n *Node) String() string

Jump to

Keyboard shortcuts

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