Documentation ¶
Index ¶
- Constants
- func AnyToBytes(data interface{}, prettyPrint bool) ([]byte, error)
- func BytesToAny(data []byte, dataPtr interface{}) error
- func SafeGetValue(sd Discovery, key string, valuePtr interface{}, decompress bool) error
- func SafeSetValue(sd Discovery, key string, value interface{}, compress bool) error
- func ValueMetaToSlice(pairs []ValueMeta, dataPtr interface{}) error
- type CheckerFunc
- type Discovery
- type ServiceDesc
- func (self *ServiceDesc) Address() string
- func (self *ServiceDesc) ContainTags(tag string) bool
- func (self *ServiceDesc) Equals(sd *ServiceDesc) bool
- func (self *ServiceDesc) FormatString() string
- func (self *ServiceDesc) GetMeta(name string) string
- func (self *ServiceDesc) GetMetaAsInt(name string) int
- func (self *ServiceDesc) SetMeta(key, value string)
- func (self *ServiceDesc) String() string
- type ValueMeta
Constants ¶
View Source
const (
// 不能直接保存二进制,底层用Json转base64,base64的二进制比原二进制要大最终二进制不到512K就会达到限制
PackedValueSize = 300 * 1024
)
KV中的Value最大不超过512K,
Variables ¶
This section is empty.
Functions ¶
func AnyToBytes ¶
func BytesToAny ¶
func SafeGetValue ¶
func SafeSetValue ¶
compress value按 key, key.1, key.2 ... 保存
func ValueMetaToSlice ¶
Types ¶
type CheckerFunc ¶
type CheckerFunc func() (output, status string)
type Discovery ¶
type Discovery interface { // 注册服务 Register(*ServiceDesc) error // 解注册服务 Deregister(svcid string) error // 根据服务名查到可用的服务 Query(name string) (ret []*ServiceDesc) // 注册服务变化通知 RegisterNotify(mode string) (ret chan struct{}) // 解除服务变化通知 DeregisterNotify(mode string, c chan struct{}) // 设置值 SetValue(key string, value interface{}, optList ...interface{}) error // 取值,并赋值到变量 GetValue(key string, valuePtr interface{}) error // 删除值 DeleteValue(key string) error }
var (
Default Discovery
)
type ServiceDesc ¶
type ServiceDesc struct { Name string ID string // 所有service中唯一的id Host string Port int Tags []string // 分类标签 Meta map[string]string // 细节配置 }
注册到服务发现的服务描述
func (*ServiceDesc) Address ¶
func (self *ServiceDesc) Address() string
func (*ServiceDesc) ContainTags ¶
func (self *ServiceDesc) ContainTags(tag string) bool
func (*ServiceDesc) Equals ¶
func (self *ServiceDesc) Equals(sd *ServiceDesc) bool
func (*ServiceDesc) FormatString ¶
func (self *ServiceDesc) FormatString() string
func (*ServiceDesc) GetMeta ¶
func (self *ServiceDesc) GetMeta(name string) string
func (*ServiceDesc) GetMetaAsInt ¶
func (self *ServiceDesc) GetMetaAsInt(name string) int
func (*ServiceDesc) SetMeta ¶
func (self *ServiceDesc) SetMeta(key, value string)
func (*ServiceDesc) String ¶
func (self *ServiceDesc) String() string
Click to show internal directories.
Click to hide internal directories.