code: func (m *Monitor) ScheduleStatus(key *aurora.JobKey, instanceCount int32, desiredStatuses map[aurora.ScheduleStatus]bool, interval, timeout int) (bool, error) {
  
  	ticker := time.NewTicker(time.Second * time.Duration(interval))
  	defer ticker.Stop()
  	timer := time.NewTimer(time.Second * time.Duration(timeout))
  	defer timer.Stop()
  
  	wantedStatuses := make([]aurora.ScheduleStatus, 0)
  
  	for status := range desiredStatuses {
  		wantedStatuses = append(wantedStatuses, status)
  	}
  
  	for {
  		select {
  		case <-ticker.C:
  
  			// Query Aurora for the state of the job key ever interval
  			instCount, cliErr := m.Client.GetInstanceIds(key, wantedStatuses)
  			if cliErr != nil {
  				return false, errors.Wrap(cliErr, "Unable to communicate with Aurora")
  			}
  			if len(instCount) == int(instanceCount) {
  				return true, nil
  			}
  		case <-timer.C:
  
  			// If the timer runs out, return a timeout error to user
  			return false, newTimedoutError(errors.New("schedule status monitor timed out"))
  		}
  	}
  }
docs: // Monitor a Job until all instances enter a desired status.
  // Defaults sets of desired statuses provided by the thrift API include:
  // ACTIVE_STATES, SLAVE_ASSIGNED_STATES, LIVE_STATES, and TERMINAL_STATES