jerluc / pir

A simple multicast LAN discovery library
Apache License 2.0
6 stars 0 forks source link

Pir

GoDoc Build Status

Pir is a simple library for facilitating in device discovery on a LAN.

Installation

Using go get
go get github.com/jerluc/pir
From source
git clone https://github.com/jerluc/pir.git
cd pir
go install

Example usage

Basic usage (full source)
// Start a healthcheck server
healthcheck := pir.NewHealthCheck()
healthcheck.Start()

// Create a new peer
peer, _ := pir.NewPeer("tcp://10.1.1.1:80", healthcheck.URISpec())

// Join the group on port 9999
group := pir.NewGroup(group, 9999)
peer.Join(group)
Receiving membership updates
group.AddListener(func(event pir.MembershipEvent) bool {
  fmt.Println("Membership change event has occurred:", event)
  return true
})

Discovery protocol

Presently, this is done using a fairly common discovery protocol: