model

package
v0.0.0-...-555e9fd Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ETCD_VERSION_V2 = "v2"
	ETCD_VERSION_V3 = "v3"
)
View Source
const (
	ROLE_LEADER   = "leader"
	ROLE_FOLLOWER = "follower"

	STATUS_HEALTHY   = "healthy"
	STATUS_UNHEALTHY = "unhealthy"
)

Variables

View Source
var (
	ERR_CONFIG_ISNIL        = errors.New("Config is nil")
	ERR_TLS_CONFIG_ISNIL    = errors.New("TLSConfig is nil")
	ERR_ETCD_ADDRESS_EMPTY  = errors.New("Etcd connection address cannot be empty")
	ERR_UNSUPPORTED_VERSION = errors.New("Unsupported etcd version")

	ERR_ADD_KEY       = errors.New("Add key error")
	ERR_KEY_NOT_FOUND = errors.New("Key does not exist")
	ERR_KEY_NOT_DIR   = errors.New("Key is not a directory")
)

etcd 错误定义

Functions

This section is empty.

Types

type Config

type Config struct {
	EtcdId    int32    `json:"etcd_id,omitempty"`
	Version   string   `json:"version,omitempty"`
	Address   []string `json:"address,omitempty"`
	TlsEnable bool     `json:"tls_enable,omitempty"`
	CertFile  string   `json:"cert_file,omitempty"`
	KeyFile   string   `json:"key_file,omitempty"`
	CaFile    string   `json:"ca_file,omitempty"`
	Username  string   `json:"username,omitempty"`
	Password  string   `json:"password,omitempty"`
}

Config etcd 连接配置

func (*Config) String

func (c *Config) String() string

type EtcdSdk

type EtcdSdk interface {
	List(path string) (list []*Node, err error) // 显示当前path下所有key
	Val(path string) (data *Node, err error)    // 获取path的值
	Add(path string, data []byte) (err error)   // 添加key
	Put(path string, data []byte) (err error)   // 修改key
	Del(path string) (err error)                // 删除key
	Members() (members []*Member, err error)    // 获取节点列表
	Close() (err error)                         // 关闭连接
}

EtcdSdk 统一操作etcd接口

type Member

type Member struct {
	// *etcdserverpb.Member
	ID         string   `json:"ID"`
	Name       string   `json:"name"`
	PeerURLs   []string `json:"peerURLs"`
	ClientURLs []string `json:"clientURLs"`
	Role       string   `json:"role"`
	Status     string   `json:"status"`
	DbSize     int64    `json:"db_size"`
}

Member 节点信息

type Node

type Node struct {
	IsDir   bool   `json:"is_dir"`
	Path    string `json:"path"`
	Name    string `json:"name"`
	Value   string `json:"value"`
	Version int64  `json:"version"`
}

Node 一个key 目录或文件

Jump to

Keyboard shortcuts

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