Beispiel #1
0
func (ft *fakeTask) Do(e *tasks.Execution) {
	ft.timeStamps = append(ft.timeStamps, e.Now())
	if ft.err != nil {
		e.SetError(ft.err)
	}
	if ft.runDuration > 0 {
		e.Sleep(ft.runDuration)
	}
	ft.timesRun++
}
Beispiel #2
0
func multiSet(
	e *tasks.Execution,
	setter Setter,
	lights []int,
	properties *gohue.LightProperties) {
	if len(lights) == 0 {
		if resp, err := setter.Set(0, properties); err != nil {
			e.SetError(fixError(0, resp, err))
			return
		}
	} else {
		for _, light := range lights {
			if light == 0 {
				e.SetError(fixError(0, kInvalidLightIdBytes, gohue.NoSuchResourceError))
				return
			}
			if resp, err := setter.Set(light, properties); err != nil {
				e.SetError(fixError(light, resp, err))
				return
			}
		}
	}
}