agent/eventhandler/task_handler.go
func (handler *TaskHandler) startDrainEventsTicker() {
	derivedCtx, cancel := context.WithCancel(handler.ctx)
	defer cancel()
	ticker := utils.NewJitteredTicker(derivedCtx, handler.minDrainEventsFrequency, handler.maxDrainEventsFrequency)
	for {
		select {
		case <-handler.ctx.Done():
			seelog.Infof("TaskHandler: Stopping periodic container state change submission ticker")
			return
		case <-ticker:
			// Gather a list of task state changes to send. This list is
			// constructed from the tasksToEvents map based on the task
			// arns of containers that haven't been sent to ECS yet.
			for _, taskEvent := range handler.taskStateChangesToSend() {
				seelog.Infof(
					"TaskHandler: Adding a state change event to send batched container events: %s",
					taskEvent.String())
				// Force start the the task state change submission
				// workflow by calling AddStateChangeEvent method.
				handler.AddStateChangeEvent(taskEvent, handler.client)
			}
		}
	}
}
func (handler *TaskHandler) startDrainEventsTicker() {
	derivedCtx, cancel := context.WithCancel(handler.ctx)
	defer cancel()
	ticker := utils.NewJitteredTicker(derivedCtx, handler.minDrainEventsFrequency, handler.maxDrainEventsFrequency)
	for {
		select {
		case <-handler.ctx.Done():
			seelog.Infof("TaskHandler: Stopping periodic container state change submission ticker")
			return
		case <-ticker:
			// Gather a list of task state changes to send. This list is
			// constructed from the tasksToEvents map based on the task
			// arns of containers that haven't been sent to ECS yet.
			for _, taskEvent := range handler.taskStateChangesToSend() {
				seelog.Infof(
					"TaskHandler: Adding a state change event to send batched container events: %s",
					taskEvent.String())
				// Force start the the task state change submission
				// workflow by calling AddStateChangeEvent method.
				handler.AddStateChangeEvent(taskEvent, handler.client)
			}
		}
	}
}
func ( handler * TaskHandler ) startDrainEventsTicker ( ) { derivedCtx , cancel := context . WithCancel ( handler . ctx ) defer cancel ( ) ticker := utils . NewJitteredTicker ( derivedCtx , handler . minDrainEventsFrequency , handler . maxDrainEventsFrequency ) for { select { case <- handler . ctx . Done ( ) : seelog . Infof ( " " ) return case <- ticker : // Gather a list of task state changes to send. This list is // constructed from the tasksToEvents map based on the task // arns of containers that haven't been sent to ECS yet. for _ , taskEvent := range handler . taskStateChangesToSend ( ) { seelog . Infof ( " " , taskEvent . String ( ) ) // Force start the the task state change submission // workflow by calling AddStateChangeEvent method. handler . AddStateChangeEvent ( taskEvent , handler . client ) } } } }
// startDrainEventsTicker starts a ticker that periodically drains the events queue
// by submitting state change events to the ECS backend
startDrainEventsTicker starts a ticker that periodically drains the events queue by submitting state change events to the ECS backend