etcd

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

封装了一些 etcd 的常用操作 之前是给 plemis 使用的 , 后续看缓存或者配置文件是否要用

etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 https://skyao.gitbooks.io/learning-etcd3/content/documentation/op-guide/configuration.html#--advertise-client-urls https://etcd.readthedocs.io/en/latest/

Index

Constants

This section is empty.

Variables

View Source
var (
	KEY_URL = "116.62.230.114:2379"
	GR_URL  = "47.110.8.212:2379"
	GR_URL2 = "47.110.8.212:2479"
)
View Source
var EtcdPrefix = "/xiao/116.62.230.114/9001"

EtcdPrefix 当前应用配置的前缀

Functions

func CheckRegisted

func CheckRegisted() bool

@since 0.0.1 @since 0.0.10 底层方法重写

func DELETEEtcd

func DELETEEtcd(c *gin.Context)

func Delete

func Delete(key string) error

func Get

func Get(key string) (string, error)

func GetByPrefix

func GetByPrefix(prefix string) (*[]KV, error)

func GetEtcd

func GetEtcd(c *gin.Context)

func GetEtcds

func GetEtcds(c *gin.Context)

@since 0.0.10 获取多条

func GetString

func GetString(key string) (string, error)

GetString 获取 String @since 0.0.1 @since 0.0.10 底层方法重写,因用于Xiao项目 所以打上固定前缀避免冲突

func PUTEtcd

func PUTEtcd(c *gin.Context)

func Put

func Put(key string, value string) error

func PutKey

func PutKey(key, val string) error

PutKey 设置String @since 0.0.1 @since 0.0.10 底层方法重写,因用于Xiao项目 所以打上固定前缀避免冲突

func Register

func Register()

Register 注册 @since 0.0.1 @since 0.0.10 重写 etcd

func RegisterSelf

func RegisterSelf()

RegisterSelf 将自己注册到 ETCD @since 0.0.1

Types

type DELETEEtcdForm

type DELETEEtcdForm struct {
	Key string `json:"key" binding:'required'`
}

type EtcdClient

type EtcdClient struct {
	// contains filtered or unexported fields
}

func New

func New() *EtcdClient

func (*EtcdClient) Delete

func (c *EtcdClient) Delete(key string) error

func (*EtcdClient) Get

func (c *EtcdClient) Get(key string) (string, error)

Get 获取值

func (*EtcdClient) GetByPrefix

func (c *EtcdClient) GetByPrefix(prefix string) (*[]KV, error)

GetByPrefix 通过前缀获取值

func (*EtcdClient) Put

func (c *EtcdClient) Put(key string, value string) error

Put 设置值

type GetEtcdFrom

type GetEtcdFrom struct {
	Key string `form:"key"`
}

type KV

type KV struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type PUTEtcdFrom

type PUTEtcdFrom struct {
	Key   string `json:"key" binding:'required'`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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