grapeEtcd

package
v0.0.0-...-5771147 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// etcd内部客户端
	EtcdCli *clientv3.Client = nil

	// 验证
	IsAuth       bool   = false
	AuthUserName string = "root"
	AuthPassword string = "123123"
)

Functions

func BindWatcher

func BindWatcher(key string, wFunc EtcdHandler, args ...interface{}) error

///////////////////////////////////////////////////////////// watcher watcher函数第一个参数必须是string,会自动传入type,否则无法绑定 watcher函数第二个参数必须是[]byte,会自动传入key,否则无法绑定 watcher函数第三个个参数必须是[]byte,会自动传入value,否则无法绑定 watcher example:func TestCallback(type string,value []byte,testInt int,testFloat float32)

func BindWatcherPrefix

func BindWatcherPrefix(key string, isPrefix bool, wFunc EtcdHandler, args ...interface{}) error

func Close

func Close()

func Delete

func Delete(key string, prefix bool) error

删除Key

func Dial

func Dial(urls []string) error

func DialTimeout

func DialTimeout(urls []string, timeout time.Duration) error

func Grent

func Grent(ttl int64) (resp *clientv3.LeaseGrantResponse, err error)

创建一个租约

func Keeplive

func Keeplive(Id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)

持续续约 会开启一个持续的携程去续约这个租约

func KeepliveOnce

续约一次 本次只续约一次,过后依旧会删除

func MarshalKey

func MarshalKey(key string, val interface{}) error

func MarshalKeyTTL

func MarshalKeyTTL(key string, val interface{}, ttl int64) (Id clientv3.LeaseID, err error)

func Read

func Read(key string) (body []byte, err error)

///////////////////////////////////////////////////////////// 读写函数

func ReadAll

func ReadAll(key string) (body *clientv3.GetResponse, err error)

func Revoke

强制取消租约

func SetFormatter

func SetFormatter(in Formatter)

func StopWatcher

func StopWatcher(key string) error

func TimeToLive

func TimeToLive(Id clientv3.LeaseID) (resp *clientv3.LeaseTimeToLiveResponse, err error)

func UnmarshalKey

func UnmarshalKey(key string, val interface{}) error

func Write

func Write(key string, val []byte) error

func WriteGrent

func WriteGrent(key string, val []byte, Id clientv3.LeaseID) error

func WriteTTL

func WriteTTL(key string, val []byte, ttl int64) (Id clientv3.LeaseID, err error)

Types

type BsonFormatter

type BsonFormatter struct {
}

//////////////////////////////////////////////// bson的格式化

func (*BsonFormatter) FromString

func (f *BsonFormatter) FromString(convert string) []byte

func (*BsonFormatter) Marshal

func (f *BsonFormatter) Marshal(v interface{}) ([]byte, error)

func (*BsonFormatter) ToString

func (f *BsonFormatter) ToString(convert []byte) string

func (*BsonFormatter) Unmarshal

func (f *BsonFormatter) Unmarshal(data []byte, v interface{}) error

type EtcdHandler

type EtcdHandler interface{}

type EtcdWatcher

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

func (*EtcdWatcher) Close

func (w *EtcdWatcher) Close()

type Formatter

type Formatter interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
	ToString(convert []byte) string
	FromString(convert string) []byte
}

格式化CallBack

type JsonFormatter

type JsonFormatter struct {
}

内建支持json和base64等 //////////////////////////////////////////////// json格式化

func (*JsonFormatter) FromString

func (f *JsonFormatter) FromString(convert string) []byte

func (*JsonFormatter) Marshal

func (f *JsonFormatter) Marshal(v interface{}) ([]byte, error)

func (*JsonFormatter) ToString

func (f *JsonFormatter) ToString(convert []byte) string

func (*JsonFormatter) Unmarshal

func (f *JsonFormatter) Unmarshal(data []byte, v interface{}) error

type M

type M = map[string]interface{}

Jump to

Keyboard shortcuts

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