Documentation ¶
Index ¶
Constants ¶
View Source
const (
DEFAULT_CHANNEL_SIZE = 64
)
Variables ¶
View Source
var Once sync.Once
Functions ¶
This section is empty.
Types ¶
type EtcdRegister ¶
type EtcdRegister struct { Etcd3Client *etcd3.Client Logger *zap.Logger Key string //service uniq-key Value string //micro-service ip+port+weight Ttl time.Duration Ctx context.Context Cancel context.CancelFunc ApiOn bool Leaseid etcd3.LeaseID }
func NewRegister ¶
func NewRegister(config *com.RegisterConfig) (*EtcdRegister, error)
func (*EtcdRegister) ServiceRegister ¶
func (r *EtcdRegister) ServiceRegister() error
func (*EtcdRegister) ServiceUnRegister ¶
func (r *EtcdRegister) ServiceUnRegister() error
type EtcdResolver ¶
type EtcdResolver struct { Schemename string EtcdCli *etcd3.Client // etcd3 client WatchKey string Watcher *EtcdWatcher Clientconn resolver.ClientConn Wg sync.WaitGroup //CloseCh chan struct{} // 关闭 channel Logger *zap.Logger //control Ctx *context.Context Cancel context.CancelFunc }
func NewResolverRegister ¶
func NewResolverRegister(config *com.ResolverConfig) (*EtcdResolver, error)
func (*EtcdResolver) Build ¶
func (r *EtcdResolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error)
Build returns itself for resolver, because it's both a builder and a resolver.
func (*EtcdResolver) ResolveNow ¶
func (r *EtcdResolver) ResolveNow(o resolver.ResolveNowOptions)
ResolveNow is a noop for resolver.
type EtcdWatcher ¶
type EtcdWatcher struct { WatchKey string Client *etcd3.Client Ctx *context.Context Cancel context.CancelFunc AddrsList []resolver.Address WatchCh etcd3.WatchChan // watch() RETURN channel Logger *zap.Logger Wg *sync.WaitGroup }
独立封装watcher
func NewEtcdWatcher ¶
func NewEtcdWatcher(ctx *context.Context, key string, etcdclient *etcd3.Client, zaploger *zap.Logger, wg *sync.WaitGroup) *EtcdWatcher
create a etcd watcher,which belongs to etcd resolver
func (*EtcdWatcher) Close ¶
func (w *EtcdWatcher) Close()
func (*EtcdWatcher) ExtractAddrs ¶
func (w *EtcdWatcher) ExtractAddrs(etcdresponse *etcd3.GetResponse) []com.ServiceBasicInfo
get keys from etcdctl response
func (*EtcdWatcher) GetAllAddresses ¶
func (w *EtcdWatcher) GetAllAddresses() []resolver.Address
sync full addrs
Click to show internal directories.
Click to hide internal directories.