prow/config/agent.go
func (ca *Agent) Set(c *Config) {
	ca.mut.Lock()
	defer ca.mut.Unlock()
	var oldConfig Config
	if ca.c != nil {
		oldConfig = *ca.c
	}
	delta := Delta{oldConfig, *c}
	ca.c = c
	for _, subscription := range ca.subscriptions {
		go func(sub DeltaChan) { // wait a minute to send each event
			end := time.NewTimer(time.Minute)
			select {
			case sub <- delta:
			case <-end.C:
			}
			if !end.Stop() { // prevent new events
				<-end.C // drain the pending event
			}
		}(subscription)
	}
}
func (ca *Agent) Set(c *Config) {
	ca.mut.Lock()
	defer ca.mut.Unlock()
	var oldConfig Config
	if ca.c != nil {
		oldConfig = *ca.c
	}
	delta := Delta{oldConfig, *c}
	ca.c = c
	for _, subscription := range ca.subscriptions {
		go func(sub DeltaChan) { // wait a minute to send each event
			end := time.NewTimer(time.Minute)
			select {
			case sub <- delta:
			case <-end.C:
			}
			if !end.Stop() { // prevent new events
				<-end.C // drain the pending event
			}
		}(subscription)
	}
}
func ( ca * Agent ) Set ( c * Config ) { ca . mut . Lock ( ) defer ca . mut . Unlock ( ) var oldConfig Config if ca . c != nil { oldConfig = * ca . c } delta := Delta { oldConfig , * c } ca . c = c for _ , subscription := range ca . subscriptions { go func ( sub DeltaChan ) { // wait a minute to send each event end := time . NewTimer ( time . Minute ) select { case sub <- delta : case <- end . C : } if ! end . Stop ( ) { // prevent new events <- end . C // drain the pending event } } ( subscription ) } }
// Set sets the config. Useful for testing.
Set sets the config . Useful for testing .