Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrNotInit init fail ErrNotInit = errors.New("init first") //ErrFailConn fail to connect ErrFailConn = errors.New("fail to connect zk") )
Functions ¶
This section is empty.
Types ¶
type ZkElection ¶
type ZkElection struct { RootPath string NodePath string MasterPath string IsMaster bool // wait for this channel, true means master, false means follower C <-chan bool // contains filtered or unexported fields }
ZkElection election by zk
func New ¶
func New(servers []string, dir string, timeout time.Duration) *ZkElection
New create new ZkElection
func (*ZkElection) Elect ¶
func (z *ZkElection) Elect() (err error)
Elect elect for leader wait for the chan, if get a true, mean you are the leader if you already a leader, a false means you are kicked
func (*ZkElection) Init ¶
func (z *ZkElection) Init() (err error)
Init init the elections
dir is root path for election, if dir = "/project", then, election will use "/project/election" as election path and node would be "/project/election/n_xxxxxxxx" if error happens, the election would work
Click to show internal directories.
Click to hide internal directories.