discovery

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 18 Imported by: 0

README

自用基于etcd的grpc服务发现

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Log *lg.Logger

Functions

func AddServer added in v1.1.0

func AddServer(info ServiceInfo)

func BuildPrefixKey added in v1.1.0

func BuildPrefixKey(name, version string) string

func GetLocalIP added in v1.1.0

func GetLocalIP() (string, error)

func GetPublicIP added in v1.1.0

func GetPublicIP() (string, error)

func Register added in v1.1.0

func Register(ctx context.Context, eCfg EtcdConfig, info *ServiceInfo)

Register 注册服务

func RemoveServer added in v1.1.0

func RemoveServer(info ServiceInfo)

func ServerActive added in v1.1.0

func ServerActive(srvID uint32) bool

func Servers added in v1.1.0

func Servers() map[uint32]string

Types

type EtcdConfig added in v1.1.0

type EtcdConfig struct {
	Endpoints []string `yaml:"endpoints" toml:"endpoints"`
	Username  string   `yaml:"username" toml:"username"`
	Password  string   `yaml:"password" toml:"password"`
}

type RegistryInfo added in v1.1.0

type RegistryInfo struct {
	Name         string `yaml:"name" toml:"name"`
	Version      string `yaml:"version" toml:"version"`
	Port         int    `yaml:"port" toml:"port"`
	ExternalAddr string `yaml:"external_addr" toml:"external_addr"` // 对外暴露地址
}

type Resolver

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

func NewResolver

func NewResolver(ctx context.Context, eCfg EtcdConfig, prefix string) *Resolver

func (*Resolver) Build

func (*Resolver) Close

func (r *Resolver) Close()

func (*Resolver) ResolveNow

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

func (*Resolver) Scheme

func (r *Resolver) Scheme() string

type ServerManager added in v1.1.0

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

ServerManager 用于读写极其极端的情况下(10000:1),读基本无锁

func NewServerManager added in v1.1.0

func NewServerManager() *ServerManager

func (*ServerManager) AddServer added in v1.1.0

func (mgr *ServerManager) AddServer(srvID uint32, uuid string)

func (*ServerManager) RemoveServer added in v1.1.0

func (mgr *ServerManager) RemoveServer(srvID uint32, uuid string)

func (*ServerManager) ServerActive added in v1.1.0

func (mgr *ServerManager) ServerActive(srvID uint32) bool

type Service

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

type ServiceInfo

type ServiceInfo struct {
	ID       int64          `json:"id" toml:"id"`
	Type     int64          `json:"type" toml:"type"`
	Name     string         `json:"name" toml:"name"`
	UUID     string         `json:"uuid" toml:"uuid"`
	Version  string         `json:"version" toml:"version"`
	Internal string         `json:"internal" toml:"internal"`
	External string         `json:"external" toml:"external"`
	Ext      map[string]any `json:"ext" toml:"ext"` // 新增扩展信息
}

ServiceInfo 服务信息

type WatchFn added in v1.1.0

type WatchFn func(bool, []byte)

type Watcher added in v0.0.4

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

func NewWatcher added in v0.0.4

func NewWatcher(ctx context.Context, eCfg EtcdConfig, prefixFn map[string][]WatchFn) *Watcher

Jump to

Keyboard shortcuts

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