kk_etcd

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllKVsBackup added in v1.3.3

func AllKVsBackup() (error, *kk_etcd_models.AllKVsBackupResponse)

func AllKVsRestore added in v1.3.3

AllKVsRestore will overwrite exist kv

func CheckKeyExist added in v1.4.0

func CheckKeyExist(key string) error

func GetClient added in v1.4.0

func GetClient() *clientv3.Client

func GetGrpcClient added in v1.4.0

func GetGrpcClient[T any](serverName string,
	clientBuilder func(grpcConn grpc.ClientConnInterface) (client T),
	opts ...grpc.DialOption) (conn *grpc.ClientConn, client T, err error)

GetGrpcClient get grpc client for serverName

don't forget to close conn conn.Close()

func GetJson added in v1.4.0

func GetJson(key string, structPtr any) error

GetJson get json from etcd and unmarshal to structPtr eg: GetJson("configKey", &Config)

func GetYaml added in v1.4.0

func GetYaml(key string, structPtr any) error

GetYaml get yaml from etcd and unmarshal to structPtr eg: GetYaml("configKey", &Config)

func KVDel added in v1.4.0

func KVGet added in v1.4.0

func KVList added in v1.4.0

func KVPut added in v1.4.0

func PutExistUpdateJson added in v1.4.0

func PutExistUpdateJson(key string, structPtr any) error

func PutExistUpdateYaml added in v1.4.0

func PutExistUpdateYaml(key string, structPtr any) error

func PutJson added in v1.4.0

func PutJson(key string, structPtr any) error

PutJson put struct to etcd in json format, key should not exist

func PutYaml added in v1.4.0

func PutYaml(key string, structPtr any) error

PutYaml put struct to etcd in yaml format, key should not exist recommend: use PutJson instead which is more efficient

func RegisterService added in v1.3.0

func RegisterService(registration *kk_etcd_models.ServerRegistration) error

RegisterService register service to etcd

func ServerList added in v1.3.0

ServerList serverName, should with prefix key_prefix.ServiceGrpc or key_prefix.ServiceHttp only give prefix to get all service list

func Snapshot added in v1.3.3

func Snapshot() (error, *kk_etcd_models.SnapshotResponse)

func SnapshotInfo added in v1.3.3

func SnapshotRestore added in v1.3.3

func SnapshotRestore() (error, *kk_etcd_models.SnapshotRestoreResponse)

func UpdateJson added in v1.4.0

func UpdateJson(key string, structPtr any) error

UpdateJson update struct in etcd, key should exist

func UpdateYaml added in v1.4.0

func UpdateYaml(key string, structPtr any) error

UpdateYaml update struct in etcd, key should exist

func WatchServerList added in v1.3.2

func WatchServerList(ctx context.Context, serverType kk_etcd_models.ServerType, serverName string, serverListChan chan<- *kk_etcd_models.PBListServer) (err error)

WatchServerList watch server list change

Types

type CloseFunc added in v1.4.0

type CloseFunc func() error

func InitClient added in v1.4.0

func InitClient(cfg *InitClientConfig) (CloseFunc, error)

type InitClientConfig added in v1.4.0

type InitClientConfig struct {
	Endpoints []string
	UserName  string
	Password  string
	DebugMode bool
}

func (*InitClientConfig) Check added in v1.4.0

func (x *InitClientConfig) Check()

Jump to

Keyboard shortcuts

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