code: func (r *EtcdRegistry) ScheduledUnit(name string) (*job.ScheduledUnit, error) {
  	key := r.prefixed(jobPrefix, name)
  	opts := &etcd.GetOptions{
  		Recursive: true,
  	}
  	res, err := r.kAPI.Get(context.Background(), key, opts)
  	if err != nil {
  		if isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
  			err = nil
  		}
  		return nil, err
  	}
  
  	su := job.ScheduledUnit{
  		Name:            name,
  		TargetMachineID: dirToTargetMachineID(res.Node),
  	}
  
  	var us *unit.UnitState
  	if len(su.TargetMachineID) > 0 {
  		us, err = r.getUnitState(name, su.TargetMachineID)
  		if err != nil {
  			return nil, err
  		}
  	}
  
  	js := determineJobState(dirToHeartbeat(res.Node), su.TargetMachineID, us)
  	su.State = &js
  
  	return &su, nil
  }
docs: // ScheduledUnit retrieves the ScheduledUnit by the given name from the Registry.
  // Returns nil if no such ScheduledUnit exists, and any error encountered.