func ResetWaitTimerForNextScheduledAssociation(log log.T, targetDate time.Time) {
	lock.Lock()
	defer lock.Unlock()

	if targetDate.IsZero() {
		return
	}
	// duration can be negative, which will trigger the signal immediately
	duration := targetDate.UTC().Sub(time.Now().UTC())

	if nextScheduledDate.Equal(targetDate) {
		log.Infof(scheduleForNextAssociationMessage, nextScheduledDate, duration)
		return
	}

	// Stop previous timer as the next scheduled date is changed
	if waitTimerForNextScheduledAssociation != nil {
		waitTimerForNextScheduledAssociation.Stop()
	}

	waitTimerForNextScheduledAssociation = time.NewTimer(duration)
	nextScheduledDate = targetDate

	log.Infof(scheduleForNextAssociationMessage, targetDate, duration)
	go func() {
		<-waitTimerForNextScheduledAssociation.C
		ExecuteAssociation(log)
	}()

}
// ResetWaitTimerForNextScheduledAssociation stops old wait timer and creates new one with updated target date
// It will wait until the target date then sends the signal for executing next scheduled association
ResetWaitTimerForNextScheduledAssociation stops old wait timer and creates new one with updated target date
It will wait until the target date then sends the signal for executing next scheduled association
// ResetWaitTimerForNextScheduledAssociation stops old wait timer and creates new one with updated target date // It will wait until the target date then sends the signal for executing next scheduled association
func ResetWaitTimerForNextScheduledAssociation(log log.T, targetDate time.Time) {
	lock.Lock()
	defer lock.Unlock()
	if targetDate.IsZero() {
		return
	}
	duration := targetDate.UTC().Sub(time.Now().UTC())
	if nextScheduledDate.Equal(targetDate) {
		log.Infof(scheduleForNextAssociationMessage, nextScheduledDate, duration)
		return
	}
	if waitTimerForNextScheduledAssociation != nil {
		waitTimerForNextScheduledAssociation.Stop()
	}
	waitTimerForNextScheduledAssociation = time.NewTimer(duration)
	nextScheduledDate = targetDate
	log.Infof(scheduleForNextAssociationMessage, targetDate, duration)
	go func() {
		<-waitTimerForNextScheduledAssociation.C
		ExecuteAssociation(log)
	}()
}
func ResetWaitTimerForNextScheduledAssociation ( log log . T , targetDate time . Time ) { lock . Lock ( ) defer lock . Unlock ( ) if targetDate . IsZero ( ) { return } duration := targetDate . UTC ( ) . Sub ( time . Now ( ) . UTC ( ) ) if nextScheduledDate . Equal ( targetDate ) { log . Infof ( scheduleForNextAssociationMessage , nextScheduledDate , duration ) return } if waitTimerForNextScheduledAssociation != nil { waitTimerForNextScheduledAssociation . Stop ( ) } waitTimerForNextScheduledAssociation = time . NewTimer ( duration ) nextScheduledDate = targetDate log . Infof ( scheduleForNextAssociationMessage , targetDate , duration ) go func ( ) { <- waitTimerForNextScheduledAssociation . C ExecuteAssociation ( log ) } ( ) }
ResetWaitTimerForNextScheduledAssociation stops old wait timer and creates new one with updated target date
It will wait until the target date then sends the signal for executing next scheduled association
ResetWaitTimerForNextScheduledAssociation stops old wait timer and creates new one with updated target date It will wait until the target date then sends the signal for executing next scheduled association
// duration can be negative, which will trigger the signal immediately // Stop previous timer as the next scheduled date is changed