func (m *MemberList) LocalNode() Member {
	return Member{
		member: m.list.LocalNode(),
	}
}
LocalNode is used to return the local Member
package members
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"sync"
	"github.com/go-kit/kit/log"
	"github.com/hashicorp/memberlist"
	"github.com/hashicorp/serf/cmd/serf/command/agent"
	"github.com/hashicorp/serf/serf"
	"github.com/pkg/errors"
)
const (
	defaultAgentLogLevel = "WARN"
)
type Handler interface {
	HandleEvent(Event)
}
type Members struct {
	agent    *agent.Agent
	members  *serf.Serf
	existing []string
	mutex    sync.Mutex
	handlers map[Handler]agent.EventHandler
	logger   log.Logger
}
func NewMembers(options ...Option) *Members {
	opts := newOptions()
	for _, option := range options {
		option(opts)
	}
	return &Members{
		existing: opts.existing,
		handlers: make(map[Handler]agent.EventHandler),
		logger:   opts.logger,
	}
}
func (m *Members) Init(config ...Config) error {
	actor, err := agent.Create(configTransform(config...))
	if err != nil {
		return errors.WithStack(err)
	}
	if err := actor.Start(); err != nil {
		return errors.WithStack(err)
	}
	m.mutex.Lock()
	m.agent = actor
	m.members = actor.Serf()
	m.mutex.Unlock()
	return nil
}
func (m *Members) Join() (int, error) {
	return m.members.Join(m.existing, true)
}
func (m *Members) Leave() error {
	return m.members.Leave()
}
func (m *Members) MemberList() *MemberList {
	return &MemberList{
		list:   m.members.Memberlist(),
		logger: m.logger,
	}
}
func (m *Members) Walk(fn func(PeerInfo) error) error {
	for _, v := range m.members.Members() {
		if v.Status != serf.StatusAlive {
			continue
		}
		if info, err := decodePeerInfoTag(v.Tags); err == nil {
			if e := fn(info); e != nil {
				return err
			}
		}
	}
	return nil
}
func (m *Members) AddHandler(handler Handler) {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	if h, ok := m.handlers[handler]; ok {
		delete(m.handlers, handler)
		m.agent.DeregisterEventHandler(h)
	}
	eventHandler := &EventHandler{
		handler: handler,
		logger:  log.With(m.logger, "component", "event-handler"),
	}
	m.handlers[handler] = eventHandler
	m.agent.RegisterEventHandler(eventHandler)
}
func (m *Members) RemoveHandler(handler Handler) {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	if h, ok := m.handlers[handler]; ok {
		delete(m.handlers, handler)
		m.agent.DeregisterEventHandler(h)
	}
}
func (m *Members) DispatchEvent(e Event) error {
	switch e.Type() {
	case EventUser:
		evt, ok := e.(*UserEvent)
		if !ok {
			return errors.Errorf("unsupported user event")
		}
		return m.agent.UserEvent(evt.Name, evt.Payload, true)
	default:
		return errors.Errorf("unsupported event type %v", e.Type())
	}
}
func (m *Members) Shutdown() error {
	if err := m.members.Leave(); err != nil {
		return errors.WithStack(err)
	}
	if err := m.members.Shutdown(); err != nil {
		return errors.WithStack(err)
	}
	return nil
}
type MemberList struct {
	list   *memberlist.Memberlist
	logger log.Logger
}
func (m *MemberList) NumMembers() int {
	return m.list.NumMembers()
}