Documentation ¶
Overview ¶
Package peerpicker provides a groupcache.PeerPicker that utilizes a LAN peer discovery mechanism and sets up the groupcache to use the HTTPPool for communication between nodes.
Example:
picker, err := peerpicker.New(7586) if err != nil { // Do something } fsys, err := groupcache.New(picker) if err != nil { // Do something }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IsPeer ¶
type IsPeer func(peer peerdiscovery.Discovered) (bool, string)
IsPeer determines if a discovered peer is a peer for our groupcache. Each peer will send a peer.Payload of [peer key]:[iam address], such as "groupcache:127.0.01". IsPeer() should return true if the key matches and return the iam address. We get the iam address from the message instead of the IP that sent it because discovery happens on all IPs configured for a device.
type LAN ¶
type LAN struct { *groupcache.HTTPPool // contains filtered or unexported fields }
LAN provides a groupcache.PeerPicker utilizing schollz peerdiscovery.
type Option ¶
Option is optional settings for the New() constructor.
func WithLogger ¶
WithLogger specifies a logger for us to use.
func WithSettings ¶
WithSettings allows passing your own settings for peer discovery. If not specified this will go with our own default values for ipv4 and ipv6 (if setup). We default to port 9999. iam in the net.IP that you wish to broadcast as. This defaults to an IPv6 address on hosts with IPv6.