func (s *Service) Join(addr string) error {
	err := s.store.Join(addr)
	if err == errNotLeader {
		return s.writeLeader(map[string][]byte{
			"addr": []byte(addr),
			"type": typJoin,
		})
	}
	return err
}
Join joins the node, reachable at addr, to the cluster.
package cluster
import (
	"bytes"
	"encoding/json"
	"fmt"
	"net"
	"time"
	"github.com/lodastack/store/model"
	"github.com/hashicorp/raft"
)
var errNotLeader = raft.ErrNotLeader
var (
	typCBucket         = []byte("createrBucket")
	typRBucket         = []byte("removeBucket")
	typUpdate          = []byte("update")
	typBatch           = []byte("batch")
	typCBucketNotExist = []byte("createBucketIfNotExist")
	typRkey            = []byte("removekey")
	typSetSession = []byte("setsession")
	typDelSession = []byte("delsession")
	typJoin   = []byte("join")
	typRemove = []byte("remove")
	typPeer   = []byte("peer")
	leader   = "Leader"
	follower = "Follower"
)
type response struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}
func (s *Service) SetPeer(raftAddr, apiAddr string) error {
	err := s.store.UpdateAPIPeers(map[string]string{raftAddr: apiAddr})
	if err == errNotLeader {
		return s.writeLeader(map[string][]byte{
			"api":  []byte(apiAddr),
			"raft": []byte(raftAddr),
			"type": typPeer,
		})
	}
	return err
}