naming

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package registry registers servers. A server report itself on start.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, s Registry)

Register registers a named registry. Each service has its own registry.

Types

type Config

type Config struct {
	Enable   bool      `yaml:"enable"`
	Version  string    `yaml:"version"`
	TTL      int       `yaml:"ttl"`   // 服务端检查周期实例是否健康的周期,单位s
	Token    string    `yaml:"token"` // token
	Debug    bool      `yaml:"debug"`
	Location *Location `yaml:"location"`
}

Config 配置

type Location

type Location struct {
	Region string `yaml:"region"`
	Zone   string `yaml:"zone"`
	Campus string `yaml:"compus"`
}

type PolarisRegistry

type PolarisRegistry struct {
	Provider polaris.ProviderAPI
	// contains filtered or unexported fields
}

PolarisRegistry 服务注册

func (*PolarisRegistry) Deregister

func (r *PolarisRegistry) Deregister(_ string) error

Deregister 反注册

func (*PolarisRegistry) Register

func (r *PolarisRegistry) Register(_ string, address string) error

Register 注册服务

type Registry

type Registry interface {
	Register(service string, address string) error
	Deregister(service string) error
}

Registry is the interface that defines a register.

func Add

func Add(protocol, serviceName, address string, cfg *Config) (Registry, error)

func Get

func Get(name string) Registry

Get gets a named registry.

type ServiceConfig

type ServiceConfig struct {
	Config      *Config
	Weight      int               // Weight
	InstanceID  string            // InstanceID
	Protocol    string            // 协议
	Namespace   string            // 命名空间
	ServiceName string            // 服务名
	BindAddress string            // 指定上报地址
	Metadata    map[string]string // 用户自定义 metadata 信息
}

ServiceConfig 配置

Jump to

Keyboard shortcuts

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