discovery

package module
v0.0.0-...-bd47b68 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2017 License: BSD-2-Clause Imports: 7 Imported by: 0

README

go-discovery

Muticast Discovery for Golang. This library is compatible with the Java impelemtation found here https://github.com/andy-trimble/discovery.

Build Status

See the example for usage. Here's a basic example:

d := discovery.Discovery{}
err := d.Start("server")
if err != nil {
	log.Fatal(err)
}
defer d.Shutdown()

go func() {
	for {
		actor := <-d.Discovered
		log.Printf("Discovered %+v", actor)
	}
}()

for {
	err := <-d.Err
	log.Printf("%+v", err)
}

The configuration options are specified by environment variables. The variables that can be set are as follows:

DISCOVERY_INTERFACE - The network interface to utilize - default: eth0
DISCOVERY_GROUP - The multicast group - default: 230.1.1.1
DISCOVERY_PORT - The multicast port - default: 8989
DISCOVERY_ANNOUNCE_COUNT - The number of times to announce oneself - default: 5
DISCOVERY_ANNOUNCE_WAIT - The duration between subsequent announcements - default: 500 ms

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	Role string    `json:"role"`
	IP   string    `json:"ip"`
	ID   uuid.UUID `json:"id"`
}

Actor is the struct representing discovered entities

type Discovery

type Discovery struct {
	Discovered chan Actor
	Err        chan error
	// contains filtered or unexported fields
}

Discovery is the multicast discovery agent

func (*Discovery) Shutdown

func (d *Discovery) Shutdown()

Shutdown closes all connections and channels

func (*Discovery) Start

func (d *Discovery) Start(role string) error

Start initiates the discovery process

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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