Documentation ¶
Overview ¶
====================================================
# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : common.go # Created : 2019-04-29 12:02 # Last Modified : 2019-04-29 12:02 # Describe : # # ====================================================
====================================================
# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : selection.go # Created : 2019-04-29 11:06 # Last Modified : 2019-04-29 11:06 # Describe : # # ====================================================
====================================================
# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : interface.go # Created : 2019-04-29 11:07 # Last Modified : 2019-04-29 11:07 # Describe : # # ====================================================
Index ¶
Constants ¶
const ( // DefaultDialTimeout dial timeout DefaultDialTimeout = time.Second * 10 )
Variables ¶
var ( // ErrKeyIsExist key exists ErrKeyIsExist = errors.New("selection: key is already exist") // ErrKeyIsNotExist key is not exist at the beginning ErrKeyIsNotExist = errors.New("selection watch: key is not exist") // ErrHeartBeatFail connection is not available ErrHeartBeatFail = errors.New("heart beat failed") // ErrIsNotLeader node is not leader ErrIsNotLeader = errors.New("selection: is not leader") )
Functions ¶
This section is empty.
Types ¶
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election automatic voting
type Elector ¶
type Elector interface { // Watch watch what happens to key Watch(ctx context.Context, key string, stopCh <-chan struct{}) (<-chan *WatchRes, error) // Put change the key-value SetNx(ctx context.Context, key string, value []byte, opt *WriteOptions) error // Delete key-value Delete(ctx context.Context, key string) error // HeartBeat checks if the connection is available HeartBeat() error }
Elector use set-watch mechanism to realize main-subordinate election
type WriteOptions ¶
type WriteOptions struct { // expire time of key TTL time.Duration // Key does not disappear until the connection is disconnected KeepAlive bool }
WriteOptions configuration when writing values
Directories ¶
Path | Synopsis |
---|---|
==================================================== # Copyright (C)2019 All rights reserved.
|
==================================================== # Copyright (C)2019 All rights reserved. |
pkg
|
|
==================================================== # Copyright (C)2019 All rights reserved.
|
==================================================== # Copyright (C)2019 All rights reserved. |