Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Watch(key string, opts ...clientv3.OpOption) Put(key string, value string, timeout time.Duration, opts ...clientv3.OpOption) (resp *clientv3.PutResponse, err error) Get(key string) (value interface{}, exists bool) GetRemote(key string, timeout time.Duration) (kvs []*mvccpb.KeyValue, err error) Delete(key string, timeout time.Duration, opts ...clientv3.OpOption) (resp *clientv3.DeleteResponse, err error) Connection() (client *clientv3.Client) Close() (err error) }
type Deserialize ¶
var ( DefaultJsonMapDeserialize Deserialize = func(data []byte) (value interface{}, err error) { var val map[string]interface{} err = jsoniter.Unmarshal(data, &val) return val, err } DefaultYamlMapDeserialize Deserialize = func(data []byte) (value interface{}, err error) { var val map[string]interface{} err = yaml.Unmarshal(data, &val) return val, err } DefaultStringDeserialize Deserialize = func(data []byte) (value interface{}, err error) { return string(data), nil } )
type Service ¶
type Service interface { //注册服务 Register(serviceTarget string, value string) //获取所有服务列表 Get(serviceTarget string) (list map[string]interface{}, exists bool) //随机取一个服务 RandOne(key string) (value interface{}, exists bool) //遍历服务,handler返回true时停止遍历 Range(key string, handler func(index string, val interface{}) (handled bool)) Close() (err error) }
func NewService ¶
func NewService(conf *clientv3.Config, prefix string, deserializers map[string]Deserialize, opts ...clientv3.OpOption) (s Service, err error)
Click to show internal directories.
Click to hide internal directories.