Documentation
¶
Index ¶
- Variables
- func GenKey(projectName string, etcdWatchMsgType string, groupID uint32, ...) string
- func GenPrefixKey(projectName string) string
- func Parse(key string) (msgType string, groupID uint32, serviceName string, serviceID uint32)
- func ValueJson2String(valueJson *ValueJson) string
- type Etcd
- func (p *Etcd) DelWithPrefix(keyPrefix string) (*etcdclientv3.DeleteResponse, error)
- func (p *Etcd) GetKey() string
- func (p *Etcd) GetPrefix(key string) (*etcdclientv3.GetResponse, error)
- func (p *Etcd) GetPrefixIntoChan() (err error)
- func (p *Etcd) KeepAlive(ctx context.Context) error
- func (p *Etcd) PutWithLease(key string, value string) (*etcdclientv3.PutResponse, error)
- func (p *Etcd) Start(ctx context.Context, value string) error
- func (p *Etcd) Stop() error
- func (p *Etcd) WatchPrefix(key string) etcdclientv3.WatchChan
- func (p *Etcd) WatchPrefixIntoChan() (err error)
- type GrpcService
- type IEtcd
- type Options
- func (p *Options) GetKey() string
- func (p *Options) WithAddCallback(callback xcontrol.ICallBack) *Options
- func (p *Options) WithDelCallback(callback xcontrol.ICallBack) *Options
- func (p *Options) WithDialTimeout(dialTimeout time.Duration) *Options
- func (p *Options) WithEndpoints(endpoints []string) *Options
- func (p *Options) WithGrantLeaseMaxRetries(retries int) *Options
- func (p *Options) WithIOut(iOut xcontrol.IOut) *Options
- func (p *Options) WithKey(key string) *Options
- func (p *Options) WithTTL(ttl int64) *Options
- func (p *Options) WithUpdateCallback(callback xcontrol.ICallBack) *Options
- func (p *Options) WithWatchKeyPrefix(watchKeyPrefix string) *Options
- type Registry
- func (p *Registry) Find(key string) (*ValueJson, bool)
- func (p *Registry) FindByGroupName(groupID uint32, serviceName string) []*ServiceInfo
- func (p *Registry) FindByGroupNameID(groupID uint32, serviceName string, serviceID uint32) []*ValueJson
- func (p *Registry) Update(key string, value *ValueJson)
- type ServerNet
- type ServiceInfo
- type ValueJson
Constants ¶
This section is empty.
Variables ¶
View Source
var GRegistry = NewRegistry()
Functions ¶
func GenPrefixKey ¶
func ValueJson2String ¶
Types ¶
type Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
func (*Etcd) DelWithPrefix ¶
func (p *Etcd) DelWithPrefix(keyPrefix string) (*etcdclientv3.DeleteResponse, error)
DelWithPrefix 删除键值 匹配的键值
func (*Etcd) GetPrefix ¶
func (p *Etcd) GetPrefix(key string) (*etcdclientv3.GetResponse, error)
GetPrefix 查找以key为前缀的所有 key value
func (*Etcd) GetPrefixIntoChan ¶
GetPrefixIntoChan 取得关心的前缀,放入 chan 中
func (*Etcd) PutWithLease ¶
func (p *Etcd) PutWithLease(key string, value string) (*etcdclientv3.PutResponse, error)
PutWithLease 将一个键值对放入etcd中 WithLease 带ttl
func (*Etcd) WatchPrefix ¶
func (p *Etcd) WatchPrefix(key string) etcdclientv3.WatchChan
WatchPrefix 监视以key为前缀的所有 key value
func (*Etcd) WatchPrefixIntoChan ¶
WatchPrefixIntoChan 监听key变化,放入 chan 中
type GrpcService ¶
type IEtcd ¶
type IEtcd interface {
Start(ctx context.Context, value string) error
Stop() error
GetKey() string
PutWithLease(key string, value string) (*etcdclientv3.PutResponse, error)
KeepAlive(ctx context.Context) error
}
var GEtcd IEtcd
type Options ¶
type Options struct {
AddCallback xcontrol.ICallBack // 增加回调 [default: nil]
UpdateCallback xcontrol.ICallBack // 更新回调 [default: nil]
DelCallback xcontrol.ICallBack // 删除回调 [default: nil]
// contains filtered or unexported fields
}
func MergeOptions ¶
func (*Options) WithAddCallback ¶
func (*Options) WithDelCallback ¶
func (*Options) WithDialTimeout ¶
func (*Options) WithEndpoints ¶
func (*Options) WithGrantLeaseMaxRetries ¶
func (*Options) WithUpdateCallback ¶
func (*Options) WithWatchKeyPrefix ¶
type Registry ¶
type Registry struct {
DataMap *xmap.MapMutexMgr[string, *ValueJson]
}
记录-服务信息
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) FindByGroupName ¶
func (p *Registry) FindByGroupName(groupID uint32, serviceName string) []*ServiceInfo
func (*Registry) FindByGroupNameID ¶
type ServiceInfo ¶
type ValueJson ¶
type ValueJson struct {
ServerNet []*ServerNet `json:"serverNet,omitempty"` // 有:直接使用. 没有:使用 etcd.ServerNet
Version string `json:"version,omitempty"` // 有:直接使用. 没有:使用 base.version 生成
AvailableLoad uint32 `json:"availableLoad,omitempty"` // 剩余可用负载, 可用资源数
SecondOffset int64 `json:"secondOffset,omitempty"` // 服务 时间(秒)偏移量
GrpcService *GrpcService `json:"grpcService,omitempty"` // gRPC 服务信息
}
ValueJson etcd 通讯的数据,由服务中的数据生成,定时更新->etcd->服务
func ValueString2Json ¶
Click to show internal directories.
Click to hide internal directories.