func (c *Controller) AppendServiceHandler(f func(*model.Service, model.Event)) error {
	for _, r := range c.registries {
		if err := r.AppendServiceHandler(f); err != nil {
			glog.V(2).Infof("Fail to append service handler to adapter %s", r.Name)
			return err
		}
	}
	return nil
}
AppendServiceHandler implements a service catalog operation
package aggregate
import (
	"github.com/golang/glog"
	multierror "github.com/hashicorp/go-multierror"
	"istio.io/pilot/model"
	"istio.io/pilot/platform"
)
type Registry struct {
	Name platform.ServiceRegistry
	model.Controller
	model.ServiceDiscovery
	model.ServiceAccounts
}
type Controller struct {
	registries []Registry
}
func NewController() *Controller {
	return &Controller{
		registries: make([]Registry, 0),
	}
}
func (c *Controller) AddRegistry(registry Registry) {
	c.registries = append(c.registries, registry)
}
func (c *Controller) Services() ([]*model.Service, error) {
	services := make([]*model.Service, 0)
	var errs error
	for _, r := range c.registries {
		svcs, err := r.Services()
		if err != nil {
			errs = multierror.Append(errs, err)
		} else {
			services = append(services, svcs...)
		}
	}
	return services, errs
}
func (c *Controller) GetService(hostname string) (*model.Service, error) {
	var errs error
	for _, r := range c.registries {
		service, err := r.GetService(hostname)
		if err != nil {
			errs = multierror.Append(errs, err)
		} else if service != nil {
			if errs != nil {
				glog.Warningf("GetService() found match but encountered an error: %v", errs)
			}
			return service, nil
		}
	}
	return nil, errs
}
func (c *Controller) ManagementPorts(addr string) model.PortList {
	for _, r := range c.registries {
		if portList := r.ManagementPorts(addr); portList != nil {
			return portList
		}
	}
	return nil
}
func (c *Controller) Instances(hostname string, ports []string,
	labels model.LabelsCollection) ([]*model.ServiceInstance, error) {
	var instances []*model.ServiceInstance
	var errs error
	for _, r := range c.registries {
		var err error
		instances, err = r.Instances(hostname, ports, labels)
		if err != nil {
			errs = multierror.Append(errs, err)
		} else if len(instances) > 0 {
			if errs != nil {
				glog.Warningf("Instances() found match but encountered an error: %v", errs)
			}
			return instances, nil
		}
	}
	return instances, errs
}
func (c *Controller) HostInstances(addrs map[string]bool) ([]*model.ServiceInstance, error) {
	out := make([]*model.ServiceInstance, 0)
	var errs error
	for _, r := range c.registries {
		instances, err := r.HostInstances(addrs)
		if err != nil {
			errs = multierror.Append(errs, err)
		} else {
			out = append(out, instances...)
		}
	}
	if len(out) > 0 {
		if errs != nil {
			glog.Warningf("HostInstances() found match but encountered an error: %v", errs)
		}
		return out, nil
	}
	return out, errs
}
func (c *Controller) Run(stop <-chan struct{}) {
	for _, r := range c.registries {
		go r.Run(stop)
	}
	<-stop
	glog.V(2).Info("Registry Aggregator terminated")
}