etcd

package
v0.0.0-...-d989b54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathSeparator    = string(filepath.Separator)
	GokeeperRootPath = "gokeeper"
	ConfRootPath     = "conf"

	VersionRootPath    = "version"
	AllVersionPath     = "all"
	CurrentVersionPath = "current"

	AddrRootPath = "addr"

	//租约path
	LeaseRootPath = "lease"
	NodeLeasePath = "node"

	LockRootPath = "lock"

	CronPath = "cron"
)

Variables

View Source
var (
	ErrKeyNotExist = errors.New("key not exist")
)

Functions

func NewLocker

func NewLocker(session *concurrency.Session, pfx string) *lockerMutex

Types

type Recode

type Recode struct {
	ID             int64  `json:"id"` //用于兼容老版本gokeeper
	Domain         string `json:"domain"`
	Version        int64  `json:"version"`
	PackageVersion int64  `json:"package_version"` // etcdVersion
	Note           string `json:"note"`            // 备注
	Timestamp      int64  `json:"timestamp"`       // 时间
}

type StorageEtcd

type StorageEtcd struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewEtcdStorage

func NewEtcdStorage(endpoints []string, username, password string, logger *logger.Logger) (*StorageEtcd, error)

func (*StorageEtcd) AddFile

func (se *StorageEtcd) AddFile(domain, file string, data map[string]map[string]string, note string) error

如果该文件已经存在,则更新

func (*StorageEtcd) DelDomain

func (se *StorageEtcd) DelDomain(domain string, note string) error

TODO:是否需要同时删除version

func (*StorageEtcd) DelFile

func (se *StorageEtcd) DelFile(domain, file, note string) error

func (*StorageEtcd) DelKeeperAddr

func (se *StorageEtcd) DelKeeperAddr(domain, nodeID, preAddr string) error

func (*StorageEtcd) DelKey

func (se *StorageEtcd) DelKey(domain, file, section, key, note string) error

func (*StorageEtcd) GetAliveKeeperNodes

func (se *StorageEtcd) GetAliveKeeperNodes(withLock bool) (map[int64]string, error)

func (*StorageEtcd) GetCurrentVersion

func (se *StorageEtcd) GetCurrentVersion(domain string, withLock bool) (int64, error)

func (*StorageEtcd) GetDomain

func (se *StorageEtcd) GetDomain(domain string, withLock bool) (map[string]map[string]map[string]string, error)

func (*StorageEtcd) GetDomainNames

func (se *StorageEtcd) GetDomainNames(withLock bool) ([]string, error)

func (*StorageEtcd) GetHistoryVersions

func (se *StorageEtcd) GetHistoryVersions(domain string, num, offset int64, withLock bool) (interface{}, error)

func (*StorageEtcd) GetKeeperAddr

func (se *StorageEtcd) GetKeeperAddr(domain, nodeID string, withLock bool) (string, error)

func (*StorageEtcd) GetKeeperAddrs

func (se *StorageEtcd) GetKeeperAddrs(domain string, withLock bool) ([]string, error)

func (*StorageEtcd) GetKey

func (se *StorageEtcd) GetKey(domain, file, section, key string, withLock bool) (string, error)

func (*StorageEtcd) GetMaxVersion

func (se *StorageEtcd) GetMaxVersion(domain string, withLock bool) (int64, error)

func (*StorageEtcd) KeepAlive

func (se *StorageEtcd) KeepAlive(id int64, addr string)

keepalive需要消费chan,如果不及时消费,keepalive会500ms请求一次心跳操作,导致qps上升 如果keepalive返回的chan被关闭,需要重新申请leaseID,然后再进行重新keepalive。(注意,超过续约时间,leaseID会失效)

func (*StorageEtcd) Rollback

func (se *StorageEtcd) Rollback(domain string, version int64, note string) error

func (*StorageEtcd) Run

func (se *StorageEtcd) Run()

func (*StorageEtcd) SetCurrentVersion

func (se *StorageEtcd) SetCurrentVersion(domain string, version int64) error

TODO

func (*StorageEtcd) SetDomain

func (se *StorageEtcd) SetDomain(domain string, data map[string]map[string]map[string]string, note string) error

func (*StorageEtcd) SetKeeperAddr

func (se *StorageEtcd) SetKeeperAddr(domain, nodeID, addr string) error

func (*StorageEtcd) SetKey

func (se *StorageEtcd) SetKey(domain, file, section, key, value, note string) error

func (*StorageEtcd) Watch

func (se *StorageEtcd) Watch(mode operate.EventModeType, storageEventChan chan<- operate.Event)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL