code: func (r *EtcdRegistry) Schedule() ([]job.ScheduledUnit, error) {
  	key := r.prefixed(jobPrefix)
  	opts := &etcd.GetOptions{
  		Sort:      true,
  		Recursive: true,
  	}
  	res, err := r.kAPI.Get(context.Background(), key, opts)
  	if err != nil {
  		if isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
  			err = nil
  		}
  		return nil, err
  	}
  
  	heartbeats := make(map[string]string)
  	uMap := make(map[string]*job.ScheduledUnit)
  
  	for _, dir := range res.Node.Nodes {
  		_, name := path.Split(dir.Key)
  		u := &job.ScheduledUnit{
  			Name:            name,
  			TargetMachineID: dirToTargetMachineID(dir),
  		}
  		heartbeats[name] = dirToHeartbeat(dir)
  		uMap[name] = u
  	}
  
  	states, err := r.statesByMUSKey()
  	if err != nil {
  		return nil, err
  	}
  
  	var sortable sort.StringSlice
  
  	// Determine the JobState of each ScheduledUnit
  	for name, su := range uMap {
  		sortable = append(sortable, name)
  		key := MUSKey{
  			MachID: su.TargetMachineID,
  			Name:   name,
  		}
  		us := states[key]
  		js := determineJobState(heartbeats[name], su.TargetMachineID, us)
  		su.State = &js
  	}
  	sortable.Sort()
  
  	units := make([]job.ScheduledUnit, 0, len(sortable))
  	for _, name := range sortable {
  		units = append(units, *uMap[name])
  	}
  	return units, nil
  }
docs: // Schedule returns all ScheduledUnits known by fleet, ordered by name