1// Copyright Istio Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package serviceregistry 16 17import ( 18 "istio.io/istio/pilot/pkg/model" 19) 20 21// Instance of a service registry. A single service registry combines the capabilities of service discovery 22// and the controller for managing asynchronous events. 23type Instance interface { 24 model.Controller 25 model.ServiceDiscovery 26 27 // Provider backing this service registry (i.e. Kubernetes, Consul, etc.) 28 Provider() ProviderID 29 30 // Cluster for which the service registry applies. Only needed for multicluster systems. 31 Cluster() string 32} 33 34var _ Instance = &Simple{} 35 36// Simple Instance implementation, where fields are set individually. 37type Simple struct { 38 ProviderID ProviderID 39 ClusterID string 40 41 model.Controller 42 model.ServiceDiscovery 43} 44 45func (r Simple) Provider() ProviderID { 46 return r.ProviderID 47} 48 49func (r Simple) Cluster() string { 50 return r.ClusterID 51} 52