code: func (handler *TaskHandler) AddStateChangeEvent(change statechange.Event, client api.ECSClient) error {
  	handler.lock.Lock()
  	defer handler.lock.Unlock()
  
  	switch change.GetEventType() {
  	case statechange.TaskEvent:
  		event, ok := change.(api.TaskStateChange)
  		if !ok {
  			return errors.New("eventhandler: unable to get task event from state change event")
  		}
  		// Task event: gather all the container events and send them
  		// to ECS by invoking the async submitTaskEvents method from
  		// the sendable event list object
  		handler.flushBatchUnsafe(&event, client)
  		return nil
  
  	case statechange.ContainerEvent:
  		event, ok := change.(api.ContainerStateChange)
  		if !ok {
  			return errors.New("eventhandler: unable to get container event from state change event")
  		}
  		handler.batchContainerEventUnsafe(event)
  		return nil
  
  	default:
  		return errors.New("eventhandler: unable to determine event type from state change event")
  	}
  }
docs: // AddStateChangeEvent queues up the state change event to be sent to ECS.
  // If the event is for a container state change, it just gets added to the
  // handler.tasksToContainerStates map.
  // If the event is for task state change, it triggers the non-blocking
  // handler.submitTaskEvents method to submit the batched container state
  // changes and the task state change to ECS