nacos

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigsUrl = "v1/cs/configs"

	//nacos 全局配置名称
	MasterConfigName = "MasterPool"
)

Variables

View Source
var GrpcPool = make(map[string][]PoolUrl, 0)

全局变量 grpc 连接池map

View Source
var Mutex sync.Mutex //定义一个锁的变量(互斥锁的关键字是Mutex,其是一个结构体,传参一定要传地址,否则就不对了)
View Source
var ServiceRoute map[string][]model.SubscribeService //本地服务缓存

Functions

func GetOutboundIp

func GetOutboundIp() string

Get preferred outbound ip of this machine

func InitDiscovery

func InitDiscovery(dsAddress, namespaceId string)

初始化服务发现

func RegisterServiceInstance

func RegisterServiceInstance(param vo.RegisterInstanceParam)

Register with default cluster and group ClusterName=DEFAULT,GroupName=DEFAULT_GROUP

func SubServices

func SubServices()

订阅

func WatchServices

func WatchServices()

监控服务变化,及时订阅最新上线的服务

Types

type ClientConnection

type ClientConnection struct {
	Conn    *grpc.ClientConn
	Message string
}

func GetGrpcConn

func GetGrpcConn(serverName string) ClientConnection

type ConfigRequest

type ConfigRequest struct {
	Tenant  string `json:"tenant"`  //租户信息,对应 Nacos 的命名空间ID字段
	DataId  string `json:"dataId"`  //配置 ID
	Group   string `json:"group"`   //配置分组
	Content string `json:"content"` //配置内容
	Type    string `json:"type"`    //配置类型
}

type InitConfigRequest

type InitConfigRequest struct {
	NamespaceId string `json:"namespaceId"` //租户信息,对应 Nacos 的命名空间ID字段
	ServerName  string `json:"serverName"`  //
	GroupName   string `json:"groupName"`   //
	Ip          string `json:"ip"`          //
	Port        int    `json:"port"`        //
}

type PoolUrl

type PoolUrl struct {
	Url    string `json:"url"`    //ip+port (10.1.1.248:7065)
	Weight int    `json:"weight"` //权重总分100
	Score  int    `json:"score"`  //当前这个实例的得分
}

Jump to

Keyboard shortcuts

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