istio
57 строк · 1.5 Кб
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"istio.io/istio/pilot/pkg/serviceregistry/provider"
20"istio.io/istio/pkg/cluster"
21)
22
23// Instance of a service registry. A single service registry combines the capabilities of service discovery
24// and the controller for managing asynchronous events.
25type Instance interface {
26model.Controller
27model.ServiceDiscovery
28
29// Provider backing this service registry (i.e. Kubernetes etc.)
30Provider() provider.ID
31
32// Cluster for which the service registry applies. Only needed for multicluster systems.
33Cluster() cluster.ID
34}
35
36var _ Instance = &Simple{}
37
38type DiscoveryController interface {
39model.Controller
40model.ServiceDiscovery
41}
42
43// Simple Instance implementation, where fields are set individually.
44type Simple struct {
45ProviderID provider.ID
46ClusterID cluster.ID
47
48DiscoveryController
49}
50
51func (r Simple) Provider() provider.ID {
52return r.ProviderID
53}
54
55func (r Simple) Cluster() cluster.ID {
56return r.ClusterID
57}
58