github.com/nacos-group/nacos-sdk-go@v1.1.4/clients/naming_client/naming_client_interface.go (about) 1 /* 2 * Copyright 1999-2020 Alibaba Group Holding Ltd. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package naming_client 17 18 import ( 19 "github.com/nacos-group/nacos-sdk-go/model" 20 "github.com/nacos-group/nacos-sdk-go/vo" 21 ) 22 23 //go:generate mockgen -destination ../../mock/mock_service_client_interface.go -package mock -source=./service_client_interface.go 24 25 type INamingClient interface { 26 27 //RegisterInstance use to register instance 28 //Ip require 29 //Port require 30 //Tenant optional 31 //Weight require,it must be lager than 0 32 //Enable require,the instance can be access or not 33 //Healthy require,the instance is health or not 34 //Metadata optional 35 //ClusterName optional,default:DEFAULT 36 //ServiceName require 37 //GroupName optional,default:DEFAULT_GROUP 38 //Ephemeral optional 39 RegisterInstance(param vo.RegisterInstanceParam) (bool, error) 40 41 //DeregisterInstance use to deregister instance 42 //Ip required 43 //Port required 44 //Tenant optional 45 //Cluster optional,default:DEFAULT 46 //ServiceName require 47 //GroupName optional,default:DEFAULT_GROUP 48 //Ephemeral optional 49 DeregisterInstance(param vo.DeregisterInstanceParam) (bool, error) 50 51 // UpdateInstance use to modify instance 52 // Ip required 53 // Port required 54 // Tenant optional 55 // Cluster optional,default:DEFAULT 56 // ServiceName require 57 // GroupName optional,default:DEFAULT_GROUP 58 // Ephemeral optional 59 // Weight require,it must be lager than 0 60 // Enable require,the instance can be access or not 61 // Metadata optional 62 UpdateInstance(param vo.UpdateInstanceParam) (bool, error) 63 64 //GetService use to get service 65 //ServiceName require 66 //Clusters optional,default:DEFAULT 67 //GroupName optional,default:DEFAULT_GROUP 68 GetService(param vo.GetServiceParam) (model.Service, error) 69 70 //SelectAllInstance return all instances,include healthy=false,enable=false,weight<=0 71 //ServiceName require 72 //Clusters optional,default:DEFAULT 73 //GroupName optional,default:DEFAULT_GROUP 74 SelectAllInstances(param vo.SelectAllInstancesParam) ([]model.Instance, error) 75 76 //SelectInstances only return the instances of healthy=${HealthyOnly},enable=true and weight>0 77 //ServiceName require 78 //Clusters optional,default:DEFAULT 79 //GroupName optional,default:DEFAULT_GROUP 80 //HealthyOnly optional 81 SelectInstances(param vo.SelectInstancesParam) ([]model.Instance, error) 82 83 //SelectInstances return one instance by WRR strategy for load balance 84 //And the instance should be health=true,enable=true and weight>0 85 //ServiceName require 86 //Clusters optional,default:DEFAULT 87 //GroupName optional,default:DEFAULT_GROUP 88 SelectOneHealthyInstance(param vo.SelectOneHealthInstanceParam) (*model.Instance, error) 89 90 //Subscribe use to subscribe service change event 91 //ServiceName require 92 //Clusters optional,default:DEFAULT 93 //GroupName optional,default:DEFAULT_GROUP 94 //SubscribeCallback require 95 Subscribe(param *vo.SubscribeParam) error 96 97 //Unsubscribe use to unsubscribe service change event 98 //ServiceName require 99 //Clusters optional,default:DEFAULT 100 //GroupName optional,default:DEFAULT_GROUP 101 //SubscribeCallback require 102 Unsubscribe(param *vo.SubscribeParam) error 103 104 //GetAllServicesInfo use to get all service info by page 105 GetAllServicesInfo(param vo.GetAllServiceInfoParam) (model.ServiceList, error) 106 }