registry

package
v0.0.0-...-db9179b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceDiscovery

type ServiceDiscovery interface {
	// GetService 获取服务实例
	GetService(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
	Watch(ctx context.Context, serviceName string) (Watcher, error)
}

ServiceDiscovery 服务发现 1.本地缓存 (不需要每次请求服务,都去注册中心拿取) 2.与注册中心长连接 3.服务实例发生变化,直接推送给订阅端.

type ServiceInstance

type ServiceInstance struct {
	ID       string            `json:"id"`       // 服务ID
	Name     string            `json:"name"`     // 服务名称
	Version  string            `json:"version"`  // 服务版本
	Metadata map[string]string `json:"metadata"` // 服务元数据

	// http://127.0.0.1:8000
	// grpc://127.0.0.1:9000
	Endpoints []string `json:"endpoints"`
}

type ServiceRegistrar

type ServiceRegistrar interface {
	// Registry 注册服务
	Registry(ctx context.Context, service *ServiceInstance) error
	// Deregister 注销服务
	Deregister(ctx context.Context, service *ServiceInstance) error
}

ServiceRegistrar 服务注册

type Watcher

type Watcher interface {
	Next() ([]*ServiceInstance, error)
	Stop() error
}

Jump to

Keyboard shortcuts

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