discovery

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GrpcDiscoveryPrefix = "service://"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoints   []string
	DialTimeout int64
	HeartTime   int64
}

type Discovery

type Discovery struct {
	HeartTime int64
	Config    Config
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Discovery, error)

func (*Discovery) Register

func (d *Discovery) Register(ctx context.Context, node Service) error

func (*Discovery) Resolve

func (d *Discovery) Resolve(ctx context.Context, handlers []ResolveHandler) error

type Register

type Register interface {
	Register(ctx context.Context, node Service) error
}

type ResolveHandler

type ResolveHandler func(EnventType, Service)

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, handlers []ResolveHandler) error
}

type Service

type Service struct {
	AppID    string            `json:"app_id"`
	Name     string            `json:"name"`
	Host     string            `json:"host"`
	Port     int               `json:"port"`
	Metadata map[string]string `json:"metadata"`
}

func (Service) Key

func (s Service) Key() string

func (Service) Value

func (s Service) Value() string

func (Service) WatchKey

func (s Service) WatchKey() string

type Watcher

type Watcher interface {
	Watch(string, bool, func(*clientv3.Event))
	Shutdown()
}

func NewWatcher

func NewWatcher(ctx context.Context, brokers []string) (Watcher, error)

func NewWatcherWithClient

func NewWatcherWithClient(ctx context.Context, cli *clientv3.Client) Watcher

Jump to

Keyboard shortcuts

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