naming_client

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 31 Imported by: 249

Documentation

Overview

* Copyright 1999-2020 Alibaba Group Holding Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const DefaultBeatThreadNum = 20
View Source
const Default_Update_Thread_Num = 20

Variables

View Source
var (
	GZIP_MAGIC = []byte("\x1F\x8B")
)

Functions

func IsGzipFile

func IsGzipFile(data []byte) bool

func TryDecompressData

func TryDecompressData(data []byte) string

Types

type BeatReactor

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

func NewBeatReactor

func NewBeatReactor(serviceProxy NamingProxy, clientBeatInterval int64) BeatReactor

func (*BeatReactor) AddBeatInfo

func (br *BeatReactor) AddBeatInfo(serviceName string, beatInfo *model.BeatInfo)

func (*BeatReactor) RemoveBeatInfo

func (br *BeatReactor) RemoveBeatInfo(serviceName string, ip string, port uint64)

type Chooser

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

type HostReactor

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

func NewHostReactor

func NewHostReactor(serviceProxy NamingProxy, cacheDir string, updateThreadNum int, notLoadCacheAtStart bool, subCallback SubscribeCallback, updateCacheWhenEmpty bool) HostReactor

func (*HostReactor) GetAllServiceInfo

func (hr *HostReactor) GetAllServiceInfo(nameSpace, groupName string, pageNo, pageSize uint32) (model.ServiceList, error)

func (*HostReactor) GetServiceInfo

func (hr *HostReactor) GetServiceInfo(serviceName string, clusters string) (model.Service, error)

func (*HostReactor) ProcessServiceJson

func (hr *HostReactor) ProcessServiceJson(result string)

type INamingClient

type INamingClient interface {

	//RegisterInstance use to register instance
	//Ip  require
	//Port  require
	//Tenant optional
	//Weight  require,it must be lager than 0
	//Enable  require,the instance can be access or not
	//Healthy  require,the instance is health or not
	//Metadata  optional
	//ClusterName  optional,default:DEFAULT
	//ServiceName require
	//GroupName optional,default:DEFAULT_GROUP
	//Ephemeral optional
	RegisterInstance(param vo.RegisterInstanceParam) (bool, error)

	//DeregisterInstance use to deregister instance
	//Ip required
	//Port required
	//Tenant optional
	//Cluster optional,default:DEFAULT
	//ServiceName  require
	//GroupName  optional,default:DEFAULT_GROUP
	//Ephemeral optional
	DeregisterInstance(param vo.DeregisterInstanceParam) (bool, error)

	// UpdateInstance use to modify instance
	// Ip required
	// Port required
	// Tenant optional
	// Cluster optional,default:DEFAULT
	// ServiceName  require
	// GroupName  optional,default:DEFAULT_GROUP
	// Ephemeral optional
	// Weight  require,it must be lager than 0
	// Enable  require,the instance can be access or not
	// Metadata  optional
	UpdateInstance(param vo.UpdateInstanceParam) (bool, error)

	//GetService use to get service
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	GetService(param vo.GetServiceParam) (model.Service, error)

	//SelectAllInstance return all instances,include healthy=false,enable=false,weight<=0
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error)

	//SelectInstances only return the instances of healthy=${HealthyOnly},enable=true and weight>0
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	//HealthyOnly optional
	SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error)

	//SelectInstances return one instance by WRR strategy for load balance
	//And the instance should be health=true,enable=true and weight>0
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error)

	//Subscribe use to subscribe service change event
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	//SubscribeCallback require
	Subscribe(param *vo.SubscribeParam) error

	//Unsubscribe use to unsubscribe service change event
	//ServiceName require
	//Clusters optional,default:DEFAULT
	//GroupName optional,default:DEFAULT_GROUP
	//SubscribeCallback require
	Unsubscribe(param *vo.SubscribeParam) error

	//GetAllServicesInfo use to get all service info by page
	GetAllServicesInfo(param vo.GetAllServiceInfoParam) (model.ServiceList, error)
}

type NamingClient

type NamingClient struct {
	nacos_client.INacosClient

	NamespaceId string
	// contains filtered or unexported fields
}

func NewNamingClient

func NewNamingClient(nc nacos_client.INacosClient) (NamingClient, error)

func (*NamingClient) DeregisterInstance

func (sc *NamingClient) DeregisterInstance(param vo.DeregisterInstanceParam) (bool, error)

DeregisterInstance deregister instance

func (*NamingClient) GetAllServicesInfo

func (sc *NamingClient) GetAllServicesInfo(param vo.GetAllServiceInfoParam) (model.ServiceList, error)

GetAllServicesInfo get all services info

func (*NamingClient) GetService

func (sc *NamingClient) GetService(param vo.GetServiceParam) (model.Service, error)

GetService get service info

func (*NamingClient) RegisterInstance

func (sc *NamingClient) RegisterInstance(param vo.RegisterInstanceParam) (bool, error)

RegisterInstance register instance

func (*NamingClient) SelectAllInstances

func (sc *NamingClient) SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error)

SelectAllInstances select all instances

func (*NamingClient) SelectInstances

func (sc *NamingClient) SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error)

SelectInstances select instances

func (*NamingClient) SelectOneHealthyInstance

func (sc *NamingClient) SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error)

SelectOneHealthyInstance select one healthy instance

func (*NamingClient) Subscribe

func (sc *NamingClient) Subscribe(param *vo.SubscribeParam) error

Subscribe subscribe service

func (*NamingClient) Unsubscribe

func (sc *NamingClient) Unsubscribe(param *vo.SubscribeParam) error

Unsubscribe unsubscribe service

func (*NamingClient) UpdateInstance added in v1.0.9

func (sc *NamingClient) UpdateInstance(param vo.UpdateInstanceParam) (bool, error)

UpdateInstance update information for exist instance.

type NamingProxy

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

func NewNamingProxy

func NewNamingProxy(clientCfg constant.ClientConfig, serverCfgs []constant.ServerConfig, httpAgent http_agent.IHttpAgent) (NamingProxy, error)

func (*NamingProxy) DeregisterInstance

func (proxy *NamingProxy) DeregisterInstance(serviceName string, ip string, port uint64, clusterName string, ephemeral bool) (string, error)

func (*NamingProxy) GetAllServiceInfoList

func (proxy *NamingProxy) GetAllServiceInfoList(namespace, groupName string, pageNo, pageSize uint32) (string, error)

func (*NamingProxy) GetServiceList

func (proxy *NamingProxy) GetServiceList(pageNo int, pageSize int, groupName string, selector *model.ExpressionSelector) (*model.ServiceList, error)

func (*NamingProxy) QueryList

func (proxy *NamingProxy) QueryList(serviceName string, clusters string, udpPort int, healthyOnly bool) (string, error)

func (*NamingProxy) RegisterInstance

func (proxy *NamingProxy) RegisterInstance(serviceName string, groupName string, instance model.Instance) (string, error)

func (*NamingProxy) SendBeat

func (proxy *NamingProxy) SendBeat(info *model.BeatInfo) (int64, error)

func (*NamingProxy) ServerHealthy

func (proxy *NamingProxy) ServerHealthy() bool

func (*NamingProxy) UpdateInstance added in v1.0.9

func (proxy *NamingProxy) UpdateInstance(serviceName string, ip string, port uint64, clusterName string, ephemeral bool, weight float64, enable bool, metadata map[string]string) (string, error)

type PushData

type PushData struct {
	PushType    string `json:"type"`
	Data        string `json:"data"`
	LastRefTime int64  `json:"lastRefTime"`
}

type PushReceiver

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

func NewPushReceiver added in v1.0.1

func NewPushReceiver(hostReactor *HostReactor) *PushReceiver

type SubscribeCallback

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

func NewSubscribeCallback

func NewSubscribeCallback() SubscribeCallback

func (*SubscribeCallback) AddCallbackFuncs

func (ed *SubscribeCallback) AddCallbackFuncs(serviceName string, clusters string, callbackFunc *func(services []model.SubscribeService, err error))

func (*SubscribeCallback) RemoveCallbackFuncs

func (ed *SubscribeCallback) RemoveCallbackFuncs(serviceName string, clusters string, callbackFunc *func(services []model.SubscribeService, err error))

func (*SubscribeCallback) ServiceChanged

func (ed *SubscribeCallback) ServiceChanged(service *model.Service)

Jump to

Keyboard shortcuts

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