From 00571ad48072a6f9d14957364eebe48720fdc72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 18 Feb 2022 11:45:24 +0100 Subject: [PATCH] Worker: allow float64 for sleep duration The sleep will still be truncated to entire seconds. --- internal/worker/command_misc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/worker/command_misc.go b/internal/worker/command_misc.go index 8e8abfe5..a072c7b0 100644 --- a/internal/worker/command_misc.go +++ b/internal/worker/command_misc.go @@ -60,9 +60,11 @@ func (ce *CommandExecutor) cmdSleep(ctx context.Context, logger zerolog.Logger, switch v := sleepTime.(type) { case int: duration = time.Duration(v) * time.Second + case float64: + duration = time.Duration(v) * time.Second default: log.Warn().Interface("duration_in_seconds", v).Msg("bad type for setting 'duration_in_seconds', expected int") - return fmt.Errorf("bad type for setting 'duration_in_seconds', expected int, not %v", v) + return fmt.Errorf("bad type for setting 'duration_in_seconds', expected int, not %T", v) } log.Info().Str("duration", duration.String()).Msg("sleep")