code: func (r *EtcdRegistry) SaveUnitState(jobName string, unitState *unit.UnitState, ttl time.Duration) {
  	usm := unitStateToModel(unitState)
  	if usm == nil {
  		log.Errorf("Unable to save nil UnitState model")
  		return
  	}
  
  	val, err := marshal(usm)
  	if err != nil {
  		log.Errorf("Error marshalling UnitState: %v", err)
  		return
  	}
  
  	opts := &etcd.SetOptions{
  		TTL: ttl,
  	}
  
  	legacyKey := r.legacyUnitStatePath(jobName)
  	r.kAPI.Set(context.Background(), legacyKey, val, opts)
  
  	newKey := r.unitStatePath(unitState.MachineID, jobName)
  	r.kAPI.Set(context.Background(), newKey, val, opts)
  }
docs: // SaveUnitState persists the given UnitState to the Registry