discovery

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 11 Imported by: 0

README

#使用此服务发现以下两个包的版本需要注意 ##github.com/golang/protobuf/protoc-gen-go@v1.2.0 ##google.golang.org/grpc@v1.26.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log *lg.Logger

Functions

func NewResolver

func NewResolver(endpoints []string, service string, notify chan ServiceInfo) resolver.Builder

NewResolver return resolver builder endpoints example: http://127.0.0.1:2379 http://127.0.0.1:12379 http://127.0.0.1:22379" service is service name notify is service changed notify

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

resolver is the implementaion of grpc.resolve.Builder Resolver 实现grpc的grpc.resolve.Builder接口的Build与Scheme方法

func (*Resolver) Build

Build to resolver.Resolver 实现grpc.resolve.Builder接口的方法

func (*Resolver) Close

func (r *Resolver) Close()

Close

func (*Resolver) ResolveNow

func (r *Resolver) ResolveNow(rn resolver.ResolveNowOptions)

ResolveNow

func (*Resolver) Scheme

func (r *Resolver) Scheme() string

Scheme return etcd schema

type Service

type Service struct {
	ServiceInfo *ServiceInfo
	// contains filtered or unexported fields
}

func NewService

func NewService(info *ServiceInfo, endpoints []string) (service *Service, err error)

NewService 创建一个注册服务

func (*Service) Start

func (service *Service) Start()

Start 注册服务启动

func (*Service) Stop

func (service *Service) Stop()

type ServiceInfo

type ServiceInfo struct {
	ID      int64  `json:"id"`
	Name    string `json:"name"`
	Addr    string `json:"addr"`
	Version string `json:"version"`
	Delete  bool   `json:"delete"` // true 表示移除服务
}

服务信息

type Watcher added in v0.0.4

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher added in v0.0.4

func NewWatcher(etcd []string, service string) *Watcher

func (*Watcher) Watch added in v0.0.4

func (w *Watcher) Watch() chan ServiceInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL