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
- Variables
- func IsGzipFile(data []byte) bool
- func TryDecompressData(data []byte) string
- type BeatReactor
- type Chooser
- type HostReactor
- type INamingClient
- type NamingClient
- func (sc *NamingClient) DeregisterInstance(param vo.DeregisterInstanceParam) (bool, error)
- func (sc *NamingClient) GetAllServicesInfo(param vo.GetAllServiceInfoParam) (model.ServiceList, error)
- func (sc *NamingClient) GetService(param vo.GetServiceParam) (model.Service, error)
- func (sc *NamingClient) RegisterInstance(param vo.RegisterInstanceParam) (bool, error)
- func (sc *NamingClient) SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error)
- func (sc *NamingClient) SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error)
- func (sc *NamingClient) SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error)
- func (sc *NamingClient) Subscribe(param *vo.SubscribeParam) error
- func (sc *NamingClient) Unsubscribe(param *vo.SubscribeParam) error
- func (sc *NamingClient) UpdateInstance(param vo.UpdateInstanceParam) (bool, error)
- type NamingProxy
- func (proxy *NamingProxy) DeregisterInstance(serviceName string, ip string, port uint64, clusterName string, ephemeral bool) (string, error)
- func (proxy *NamingProxy) GetAllServiceInfoList(namespace, groupName string, pageNo, pageSize uint32) (string, error)
- func (proxy *NamingProxy) GetServiceList(pageNo int, pageSize int, groupName string, selector *model.ExpressionSelector) (*model.ServiceList, error)
- func (proxy *NamingProxy) QueryList(serviceName string, clusters string, udpPort int, healthyOnly bool) (string, error)
- func (proxy *NamingProxy) RegisterInstance(serviceName string, groupName string, instance model.Instance) (string, error)
- func (proxy *NamingProxy) SendBeat(info *model.BeatInfo) (int64, error)
- func (proxy *NamingProxy) ServerHealthy() bool
- func (proxy *NamingProxy) UpdateInstance(serviceName string, ip string, port uint64, clusterName string, ephemeral bool, ...) (string, error)
- type PushData
- type PushReceiver
- type SubscribeCallback
Constants ¶
const DefaultBeatThreadNum = 20
const Default_Update_Thread_Num = 20
Variables ¶
var (
GZIP_MAGIC = []byte("\x1F\x8B")
)
Functions ¶
func IsGzipFile ¶
func TryDecompressData ¶
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 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 (*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 ¶
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 (*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) RegisterInstance ¶
func (*NamingProxy) SendBeat ¶
func (proxy *NamingProxy) SendBeat(info *model.BeatInfo) (int64, error)
func (*NamingProxy) ServerHealthy ¶
func (proxy *NamingProxy) ServerHealthy() bool
type PushReceiver ¶
type PushReceiver struct {
// contains filtered or unexported fields
}
func NewPushReceiver ¶
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)