func NewEtcdClusterController(
	reconcileInterval time.Duration,
	statusReconcileInterval time.Duration,
	etcdClient etcdClientSet.Interface,
	tAppClient tAppClientSet.Interface,
	kubeClient clientset.Interface,
	etcdInformer etcdInformer.EtcdClusterInformer,
	tAppInformer tAppInformer.TAppInformer,
	podInformer coreInformers.PodInformer,
	svcInformer coreInformers.ServiceInformer,
	secretInformer coreInformers.SecretInformer,
	cmInformer coreInformers.ConfigMapInformer,
) *Controller {
	eventBroadcaster := record.NewBroadcaster()
	eventBroadcaster.StartStructuredLogging(0)
	eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
	recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "etcdcluster-controller"})
	ec := &Controller{
		reconcileInterval:       reconcileInterval,
		statusReconcileInterval: statusReconcileInterval,
		etcdClient:              etcdClient,
		tAppClient:              tAppClient,
		kubeClient:              kubeClient,
		etcdLister:              etcdInformer.Lister(),
		tAppLister:              tAppInformer.Lister(),
		podLister:               podInformer.Lister(),
		svcLister:               svcInformer.Lister(),
		secretLister:            secretInformer.Lister(),
		cmLister:                cmInformer.Lister(),
		etcdListerSynced:        etcdInformer.Informer().HasSynced,
		tAppListerSynced:        tAppInformer.Informer().HasSynced,
		podListerSynced:         podInformer.Informer().HasSynced,
		svcListerSynced:         svcInformer.Informer().HasSynced,
		secretListerSynced:      secretInformer.Informer().HasSynced,
		cmListerSynced:          cmInformer.Informer().HasSynced,
		recorder:                recorder,
		queue:                   workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "etcdcluster"),
		clusters:                make(map[string]*Cluster),
	}

	klog.Info("Setting up event handlers")

	etcdInformer.Informer().AddEventHandlerWithResyncPeriod(cache.ResourceEventHandlerFuncs{
		AddFunc:    ec.addEtcd,
		UpdateFunc: ec.updateEtcd,
		DeleteFunc: ec.deleteEtcd,
	}, 5*time.Minute)

	tAppInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc:    ec.addTApp,
		UpdateFunc: ec.updateTApp,
		DeleteFunc: ec.deleteTApp,
	})

	svcInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		UpdateFunc: ec.updateSvc,
	})

	ec.syncHandler = ec.syncEtcd

	metrics.Register()

	return ec
}
// NewEtcdClusterController create a new etcdcluster controller
NewEtcdClusterController create a new etcdcluster controller
// NewEtcdClusterController create a new etcdcluster controller
func NewEtcdClusterController(
	reconcileInterval time.Duration,
	statusReconcileInterval time.Duration,
	etcdClient etcdClientSet.Interface,
	tAppClient tAppClientSet.Interface,
	kubeClient clientset.Interface,
	etcdInformer etcdInformer.EtcdClusterInformer,
	tAppInformer tAppInformer.TAppInformer,
	podInformer coreInformers.PodInformer,
	svcInformer coreInformers.ServiceInformer,
	secretInformer coreInformers.SecretInformer,
	cmInformer coreInformers.ConfigMapInformer,
) *Controller {
	eventBroadcaster := record.NewBroadcaster()
	eventBroadcaster.StartStructuredLogging(0)
	eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
	recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "etcdcluster-controller"})
	ec := &Controller{
		reconcileInterval:       reconcileInterval,
		statusReconcileInterval: statusReconcileInterval,
		etcdClient:              etcdClient,
		tAppClient:              tAppClient,
		kubeClient:              kubeClient,
		etcdLister:              etcdInformer.Lister(),
		tAppLister:              tAppInformer.Lister(),
		podLister:               podInformer.Lister(),
		svcLister:               svcInformer.Lister(),
		secretLister:            secretInformer.Lister(),
		cmLister:                cmInformer.Lister(),
		etcdListerSynced:        etcdInformer.Informer().HasSynced,
		tAppListerSynced:        tAppInformer.Informer().HasSynced,
		podListerSynced:         podInformer.Informer().HasSynced,
		svcListerSynced:         svcInformer.Informer().HasSynced,
		secretListerSynced:      secretInformer.Informer().HasSynced,
		cmListerSynced:          cmInformer.Informer().HasSynced,
		recorder:                recorder,
		queue:                   workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "etcdcluster"),
		clusters:                make(map[string]*Cluster),
	}
	klog.Info("Setting up event handlers")
	etcdInformer.Informer().AddEventHandlerWithResyncPeriod(cache.ResourceEventHandlerFuncs{
		AddFunc:    ec.addEtcd,
		UpdateFunc: ec.updateEtcd,
		DeleteFunc: ec.deleteEtcd,
	}, 5*time.Minute)
	tAppInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc:    ec.addTApp,
		UpdateFunc: ec.updateTApp,
		DeleteFunc: ec.deleteTApp,
	})
	svcInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		UpdateFunc: ec.updateSvc,
	})
	ec.syncHandler = ec.syncEtcd
	metrics.Register()
	return ec
}
func NewEtcdClusterController ( reconcileInterval time . Duration , statusReconcileInterval time . Duration , etcdClient etcdClientSet . Interface , tAppClient tAppClientSet . Interface , kubeClient clientset . Interface , etcdInformer etcdInformer . EtcdClusterInformer , tAppInformer tAppInformer . TAppInformer , podInformer coreInformers . PodInformer , svcInformer coreInformers . ServiceInformer , secretInformer coreInformers . SecretInformer , cmInformer coreInformers . ConfigMapInformer , ) * Controller { eventBroadcaster := record . NewBroadcaster ( ) eventBroadcaster . StartStructuredLogging ( 0 ) eventBroadcaster . StartRecordingToSink ( & v1core . EventSinkImpl { Interface : kubeClient . CoreV1 ( ) . Events ( " " ) } ) recorder := eventBroadcaster . NewRecorder ( scheme . Scheme , v1 . EventSource { Component : " " } ) ec := & Controller { reconcileInterval : reconcileInterval , statusReconcileInterval : statusReconcileInterval , etcdClient : etcdClient , tAppClient : tAppClient , kubeClient : kubeClient , etcdLister : etcdInformer . Lister ( ) , tAppLister : tAppInformer . Lister ( ) , podLister : podInformer . Lister ( ) , svcLister : svcInformer . Lister ( ) , secretLister : secretInformer . Lister ( ) , cmLister : cmInformer . Lister ( ) , etcdListerSynced : etcdInformer . Informer ( ) . HasSynced , tAppListerSynced : tAppInformer . Informer ( ) . HasSynced , podListerSynced : podInformer . Informer ( ) . HasSynced , svcListerSynced : svcInformer . Informer ( ) . HasSynced , secretListerSynced : secretInformer . Informer ( ) . HasSynced , cmListerSynced : cmInformer . Informer ( ) . HasSynced , recorder : recorder , queue : workqueue . NewNamedRateLimitingQueue ( workqueue . DefaultControllerRateLimiter ( ) , " " ) , clusters : make ( map [ string ] * Cluster ) , } klog . Info ( " " ) etcdInformer . Informer ( ) . AddEventHandlerWithResyncPeriod ( cache . ResourceEventHandlerFuncs { AddFunc : ec . addEtcd , UpdateFunc : ec . updateEtcd , DeleteFunc : ec . deleteEtcd , } , 5 * time . Minute ) tAppInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : ec . addTApp , UpdateFunc : ec . updateTApp , DeleteFunc : ec . deleteTApp , } ) svcInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { UpdateFunc : ec . updateSvc , } ) ec . syncHandler = ec . syncEtcd metrics . Register ( ) return ec }
NewEtcdClusterController create a new etcdcluster controller
NewEtcdClusterController create a new etcdcluster controller