func (p *Peer) State() map[string]interface{} {
	members := p.members.MemberList()
	return map[string]interface{}{
		"self":        members.LocalNode().Name(),
		"members":     memberNames(members.Members()),
		"num_members": members.NumMembers(),
	}
}
State returns a JSON-serializable dump of cluster state.
Useful for debug.
package discovery
import (
	"time"
	"github.com/go-kit/kit/log"
	"github.com/pkg/errors"
	"github.com/spoke-d/thermionic/internal/discovery/members"
)
const (
	defaultBroadcastTimeout         = time.Second * 10
	defaultMembersBroadcastInterval = time.Second * 5
	defaultLowMembersThreshold      = 1
)
type EventBus interface {
	AddHandler(members.Handler)
	RemoveHandler(members.Handler)
	DispatchEvent(members.Event) error
}
type Members interface {
	EventBus
	Join() (int, error)
	Leave() error
	MemberList() MemberList
	Walk(func(members.PeerInfo) error) error
	Shutdown() error
}
type MemberList interface {
	NumMembers() int
	LocalNode() Member
	Members() []Member
}
type Member interface {
	Name() string
	Address() string
}
type Peer struct {
	members Members
	logger  log.Logger
}
func NewPeer(
	members Members,
	logger log.Logger,
) *Peer {
	return &Peer{
		members: members,
		logger:  logger,
	}
}
func (p *Peer) Close() {}
func (p *Peer) Join() (int, error) {
	numNodes, err := p.members.Join()
	if err != nil {
		return 0, errors.WithStack(err)
	}
	return numNodes, nil
}
func (p *Peer) Leave() error {
	return p.members.Leave()
}
func (p *Peer) Name() string {
	return p.members.MemberList().LocalNode().Name()
}
func (p *Peer) Address() string {
	return p.members.MemberList().LocalNode().Address()
}
func (p *Peer) ClusterSize() int {
	return p.members.MemberList().NumMembers()
}