Copy ac := aggregate.NewController(aggregate.Options{
MeshHolder: e,
})
e.ServiceDiscovery = ac
Copy type Controller struct {
registries []serviceregistry.Instance
storeLock sync.RWMutex
meshHolder mesh.Holder
running bool
}
Copy type Instance interface {
model . Controller
model . ServiceDiscovery
// Provider backing this service registry (i.e. Kubernetes etc.)
Provider () ProviderID
// Cluster for which the service registry applies. Only needed for multicluster systems.
Cluster () string
}
Copy kubeRegistry := NewController(client, options)
m.serviceController.AddRegistry(kubeRegistry)
Copy // Services implements a service catalog operation
func (c *Controller) Services() ([]*model.Service, error) {
c.RLock()
out := make([]*model.Service, 0, len(c.servicesMap))
for _, svc := range c.servicesMap {
out = append(out, svc)
}
c.RUnlock()
sort.Slice(out, func(i, j int) bool { return out[i].Hostname < out[j].Hostname })
return out, nil
}
Copy s.serviceEntryStore = serviceentry.NewServiceDiscovery(s.configController, s.environment.IstioConfigStore, s.XDSServer)
serviceControllers.AddRegistry(s.serviceEntryStore)
Copy func (s *ServiceEntryStore) Services() ([]*model.Service, error) {
services := make([]*model.Service, 0)
for _, cfg := range s.store.ServiceEntries() {
services = append(services, convertServices(cfg)...)
}
return autoAllocateIPs(services), nil
}