registrycenter

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package registrycenter provides registry center server.

Index

Constants

View Source
const (
	// ContentTypeXML is xml content type
	ContentTypeXML = "text/xml"
	// ContentTypeJSON is JSON content type
	ContentTypeJSON = "application/json"
)

Variables

This section is empty.

Functions

func GetServiceName

func GetServiceName(instanceID string) string

GetServiceName split instanceID by '-' then return second field as the service name

func UniqInstanceID

func UniqInstanceID(serviceName string) string

UniqInstanceID creates a virtual uniq ID for every visible service in mesh

Types

type ReadyFunc

type ReadyFunc func() bool

ReadyFunc is a function to check Ingress/Egress ready to work

type Server

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

Server handle all registry about logic

func NewRegistryCenterServer

func NewRegistryCenterServer(registryType string, instanceSpec *spec.ServiceInstanceSpec,
	service *service.Service, informer informer.Informer, jmxAgent *jmxtool.AgentClient,
) *Server

NewRegistryCenterServer creates an initialized registry center server.

func (*Server) CheckRegistryBody

func (rcs *Server) CheckRegistryBody(contentType string, reqBody []byte) error

CheckRegistryBody tries to decode Eureka/Consul register request body according to the registry type.

func (*Server) CheckRegistryURL

func (rcs *Server) CheckRegistryURL(w http.ResponseWriter, r *http.Request) error

CheckRegistryURL tries to decode Nacos register request URL parameters.

func (*Server) Close

func (rcs *Server) Close()

Close closes the registry center.

func (*Server) Discovery

func (rcs *Server) Discovery() ([]*ServiceRegistryInfo, error)

Discovery gets all services' spec and default instance(local sidecar for ever) which are visible for local service

func (*Server) DiscoveryService

func (rcs *Server) DiscoveryService(serviceName string) (*ServiceRegistryInfo, error)

DiscoveryService gets one service specs with default instance

func (*Server) Register

func (rcs *Server) Register(serviceSpec *spec.Service, ingressReady ReadyFunc, egressReady ReadyFunc)

Register registers itself into mesh

func (*Server) Registered

func (rcs *Server) Registered() bool

Registered checks whether service registry or not.

func (*Server) SplitNacosServiceName

func (rcs *Server) SplitNacosServiceName(serviceName string) (string, error)

SplitNacosServiceName gets nacos servicename in GROUP_NAME@@SERVICE_NAME format

func (*Server) ToConsulCatalogService

func (rcs *Server) ToConsulCatalogService(serviceInfo *ServiceRegistryInfo) []*api.CatalogService

ToConsulCatalogService transforms service registry info to consul's service

func (*Server) ToConsulHealthService

func (rcs *Server) ToConsulHealthService(serviceInfo *ServiceRegistryInfo) []*api.ServiceEntry

ToConsulHealthService transforms service registry info to consul's serviceEntry

func (*Server) ToConsulServices

func (rcs *Server) ToConsulServices(serviceInfos []*ServiceRegistryInfo) map[string][]string

ToConsulServices transforms registry center's service info to map[string][]string structure

func (*Server) ToEurekaApp

func (rcs *Server) ToEurekaApp(serviceInfo *ServiceRegistryInfo) *eureka.Application

ToEurekaApp transforms registry center's service info to eureka's app

func (*Server) ToEurekaApps

func (rcs *Server) ToEurekaApps(serviceInfos []*ServiceRegistryInfo) *eureka.Applications

ToEurekaApps transforms registry center's service info to eureka's apps

func (*Server) ToEurekaInstanceInfo

func (rcs *Server) ToEurekaInstanceInfo(serviceInfo *ServiceRegistryInfo) *eureka.InstanceInfo

ToEurekaInstanceInfo transforms service registry info to eureka's instance

func (*Server) ToNacosInstanceInfo

func (rcs *Server) ToNacosInstanceInfo(serviceInfo *ServiceRegistryInfo) *model.Instance

ToNacosInstanceInfo transforms service registry info to nacos' instance

func (*Server) ToNacosService

func (rcs *Server) ToNacosService(serviceInfo *ServiceRegistryInfo) *model.Service

ToNacosService transforms servie registry info to nacos' service

func (*Server) ToNacosServiceDetail

func (rcs *Server) ToNacosServiceDetail(serviceInfo *ServiceRegistryInfo) *model.ServiceDetail

ToNacosServiceDetail transforms servie registry info to nacos' service

func (*Server) ToNacosServiceList

func (rcs *Server) ToNacosServiceList(serviceInfos []*ServiceRegistryInfo) *model.ServiceList

ToNacosServiceList transforms registry center's service info to nacos' apps

type ServiceRegistryInfo

type ServiceRegistryInfo struct {
	Service *spec.Service
	Ins     *spec.ServiceInstanceSpec // indicates local egress
	Version int64                     // tenant Etcd key version,
}

ServiceRegistryInfo contains service's spec, and its instance, which is the sidecar+egress port address

Jump to

Keyboard shortcuts

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