Documentation ¶
Index ¶
- Constants
- func JsonMapDeserialize(data []byte) (value interface{}, err error)
- func StringDeserialize(data []byte) (value interface{}, err error)
- func YamlMapDeserialize(data []byte) (value interface{}, err error)
- type Config
- type ConfigOption
- type Deserialize
- type Deserializer
- type KeyOption
- type Naming
Constants ¶
View Source
const ( String = "string" Json = "json" Yaml = "yaml" )
Variables ¶
This section is empty.
Functions ¶
func JsonMapDeserialize ¶
JsonMapDeserialize Json反序列化为map[string]interface{}
func StringDeserialize ¶
StringDeserialize 字符串
func YamlMapDeserialize ¶
YamlMapDeserialize Yaml反序列化为map[string]interface{}
Types ¶
type Config ¶
type Config interface { // LoadKey 加载前缀到缓存 LoadKey(prefix string, opts ...clientv3.OpOption) (err error) // Watch 监视某个Key,返回WatchChan Watch(ctx context.Context, key string, opts ...clientv3.OpOption) (wch clientv3.WatchChan) // WatchKey4Cache 监视某个Key,并修改cache WatchKey4Cache(key string, opts ...clientv3.OpOption) // Put 修改某个Key值 Put(key string, value string, timeout time.Duration, opts ...clientv3.OpOption) (resp *clientv3.PutResponse, err error) // PutContext with context修改某个Key值 PutContext(ctx context.Context, key string, value string, opts ...clientv3.OpOption) (resp *clientv3.PutResponse, err error) // Get 获取数据 Get(key string) (value interface{}, exists bool) // GetRemote 从etcd远程获取数据 GetRemote(key string, timeout time.Duration) (kvs []*mvccpb.KeyValue, err error) // GetRemoteContext with context从etcd远程获取数据 GetRemoteContext(ctx context.Context, key string) (kvs []*mvccpb.KeyValue, err error) // Delete 删除某个Key数据 Delete(key string, timeout time.Duration, opts ...clientv3.OpOption) (resp *clientv3.DeleteResponse, err error) // Connection 获取ectd config Connection() (client *clientv3.Client) // Close --- Close() (err error) }
Config etcd Config
func NewConfig ¶
func NewConfig(v3Conf *clientv3.Config, confOption ConfigOption, watchOptions ...clientv3.OpOption) (c Config, changeChan <-chan shardmap.ChangeEvent, err error)
func NewConfigWithClient ¶
func NewConfigWithClient(client *clientv3.Client, co ConfigOption, watchOptions ...clientv3.OpOption) (c Config, changeChan <-chan shardmap.ChangeEvent, err error)
type ConfigOption ¶
type ConfigOption struct { PrefixList []string `json:"prefixList" yaml:"prefixList"` KeyOptionList []KeyOption `json:"keyOptionList" yaml:"keyOptionList"` ChannelSize uint16 `json:"channelSize" yaml:"channelSize"` }
ConfigOption 配置选项
type Deserialize ¶
Deserialize 反序列化函数
type Deserializer ¶
type Deserializer interface { // Deserialize 反序列化 Deserialize(key string, val []byte) (value interface{}, err error) }
Deserializer 反序列化工具
func NewDeserializer ¶
func NewDeserializer(options map[string]KeyOption) Deserializer
NewDeserializer 实例化反序列化工具对象
type KeyOption ¶
type KeyOption struct { Key string `json:"key" yaml:"key"` Type string `json:"type" yaml:"type"` Deserialize Deserialize }
KeyOption Key配置
type Naming ¶
type Naming interface { // List 列表 List(ctx context.Context) (endpoints endpoints.Key2EndpointMap, err error) // Add 添加 Add(endpoint endpoints.Endpoint, opts ...clientv3.OpOption) (err error) // AddContext with context添加 AddContext(ctx context.Context, endpoint endpoints.Endpoint, opts ...clientv3.OpOption) (err error) // Register 注册 Register(keepAliveSecond int64, endpoint endpoints.Endpoint, opts ...clientv3.OpOption) (ch <-chan *clientv3.LeaseKeepAliveResponse, err error) // Del 删除 Del(endpoint endpoints.Endpoint, opts ...clientv3.OpOption) (err error) // DelContext with context删除 DelContext(ctx context.Context, endpoint endpoints.Endpoint, opts ...clientv3.OpOption) (err error) // ChangeEndpoint 更换 ChangeEndpoint(ctx context.Context, new endpoints.Endpoint) (err error) // DialGrpc --- DialGrpc(opts ...grpc.DialOption) (*grpc.ClientConn, error) }
Click to show internal directories.
Click to hide internal directories.