registry

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnInit

func OnInit(config map[string]interface{}, option ...Option) (err error)

func PushServiceInfo

func PushServiceInfo() (err error)

func Start

func Start() error

func Stop

func Stop() error

Types

type Consul_Registry

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

func (*Consul_Registry) GetAllServices

func (this *Consul_Registry) GetAllServices() (n []*ServiceNode)

func (*Consul_Registry) GetRpcSubById

func (this *Consul_Registry) GetRpcSubById(rId core.Rpc_Key) (n []*ServiceNode)

func (*Consul_Registry) GetServiceByCategory

func (this *Consul_Registry) GetServiceByCategory(category core.S_Category) (n []*ServiceNode)

func (*Consul_Registry) GetServiceById

func (this *Consul_Registry) GetServiceById(sId string) (n *ServiceNode, err error)

func (*Consul_Registry) GetServiceByType

func (this *Consul_Registry) GetServiceByType(sType string) (n []*ServiceNode)

func (*Consul_Registry) PushServiceInfo

func (this *Consul_Registry) PushServiceInfo() (err error)

func (*Consul_Registry) Start

func (this *Consul_Registry) Start() (err error)

func (*Consul_Registry) Stop

func (this *Consul_Registry) Stop() (err error)

type IListener

type IListener interface {
	FindServiceHandlefunc(snode ServiceNode)
	UpDataServiceHandlefunc(snode ServiceNode)
	LoseServiceHandlefunc(sId string)
}

type ISys

type ISys interface {
	Start() error
	Stop() error
	PushServiceInfo() (err error)
	GetServiceById(sId string) (n *ServiceNode, err error)
	GetServiceByType(sType string) (n []*ServiceNode)
	GetAllServices() (n []*ServiceNode)
	GetServiceByCategory(category core.S_Category) (n []*ServiceNode)
	GetRpcSubById(rId core.Rpc_Key) (n []*ServiceNode)
}

func NewSys

func NewSys(option ...Option) (sys ISys, err error)

type Nacos_Registry

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

func (*Nacos_Registry) GetAllServices

func (this *Nacos_Registry) GetAllServices() (n []*ServiceNode)

func (*Nacos_Registry) GetRpcSubById

func (this *Nacos_Registry) GetRpcSubById(rId core.Rpc_Key) (n []*ServiceNode)

func (*Nacos_Registry) GetServiceByCategory

func (this *Nacos_Registry) GetServiceByCategory(category core.S_Category) (n []*ServiceNode)

func (*Nacos_Registry) GetServiceById

func (this *Nacos_Registry) GetServiceById(sId string) (n *ServiceNode, err error)

func (*Nacos_Registry) GetServiceByType

func (this *Nacos_Registry) GetServiceByType(sType string) (n []*ServiceNode)

func (*Nacos_Registry) PushServiceInfo

func (this *Nacos_Registry) PushServiceInfo() (err error)

func (*Nacos_Registry) Start

func (this *Nacos_Registry) Start() (err error)

func (*Nacos_Registry) Stop

func (this *Nacos_Registry) Stop() (err error)

type Option

type Option func(*Options)

func SetConsul_Addr

func SetConsul_Addr(v string) Option

func SetConsul_RegisterInterval

func SetConsul_RegisterInterval(v int) Option

func SetConsul_RegisterTTL

func SetConsul_RegisterTTL(v int) Option

func SetListener

func SetListener(v IListener) Option

func SetNacos_BeatInterval

func SetNacos_BeatInterval(v int64) Option

func SetNacos_NacosAddr

func SetNacos_NacosAddr(v string) Option

func SetNacos_NamespaceId

func SetNacos_NamespaceId(v string) Option

func SetNacos_Port

func SetNacos_Port(v uint64) Option

func SetNacos_TimeoutMs

func SetNacos_TimeoutMs(v uint64) Option

func SetRegistryType

func SetRegistryType(v RegistryType) Option

func SetService

func SetService(v base.IClusterService) Option

type Options

type Options struct {
	RegistryType            RegistryType
	Service                 base.IClusterService
	Listener                IListener
	Consul_Addr             string
	Consul_RegisterInterval int //定期注册
	Consul_RegisterTTL      int
	Nacos_NamespaceId       string
	Nacos_NacosAddr         string
	Nacos_Port              uint64
	Nacos_TimeoutMs         uint64 //连接超时 ms
	Nacos_BeatInterval      int64  //心跳间隔 ms
	Nacos_RegisterTTL       int
}

type RegistryType

type RegistryType uint8
const (
	Registry_Consul RegistryType = iota
	Registry_Nacos
)

type ServiceNode

type ServiceNode struct {
	Tag          string          `json:"Tag"`          //服务集群标签
	Type         string          `json:"Type"`         //服务类型
	Category     core.S_Category `json:"Category"`     //服务列别
	Id           string          `json:"Id"`           //服务Id
	Version      string          `json:"Version"`      //服务版本
	IP           string          `json:"Ip"`           //服务Ip
	RpcId        string          `json:"RpcId"`        //服务通信Id
	PreWeight    float64         `json:"PreWeight"`    //服务负载权重
	RpcSubscribe []core.Rpc_Key  `json:"RpcSubscribe"` //服务开放接口
}

func GetAllServices

func GetAllServices() (n []*ServiceNode)

func GetRpcSubById

func GetRpcSubById(rId core.Rpc_Key) (n []*ServiceNode)

func GetServiceByCategory

func GetServiceByCategory(category core.S_Category) (n []*ServiceNode)

func GetServiceById

func GetServiceById(sId string) (n *ServiceNode, err error)

func GetServiceByType

func GetServiceByType(sType string) (n []*ServiceNode)

Jump to

Keyboard shortcuts

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