From 45a95ca4c220f9ecb9dce95216766ffca133118c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 22 Feb 2022 15:33:30 +0100 Subject: [PATCH] Worker: use time service to log current time --- internal/worker/command_blender.go | 2 +- internal/worker/command_exe.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/worker/command_blender.go b/internal/worker/command_blender.go index a9c03186..e04d62be 100644 --- a/internal/worker/command_blender.go +++ b/internal/worker/command_blender.go @@ -94,7 +94,7 @@ func (ce *CommandExecutor) cmdBlenderRender(ctx context.Context, logger zerolog. logger.Debug().Msg(line) - timestamp := time.Now().Format(timeFormat) + timestamp := ce.timeService.Now().Format(timeFormat) // %35s because trailing zeroes in the nanoseconds aren't output by the // formatted timestamp, and thus it has a variable length. Using a fixed // width in this Sprintf() call ensures the rest of the line aligns visually diff --git a/internal/worker/command_exe.go b/internal/worker/command_exe.go index 0ee67c9f..3850ba17 100644 --- a/internal/worker/command_exe.go +++ b/internal/worker/command_exe.go @@ -60,6 +60,7 @@ type CommandListener interface { // TimeService is a service that operates on time. type TimeService interface { After(duration time.Duration) <-chan time.Time + Now() time.Time } //go:generate go run github.com/golang/mock/mockgen -destination mocks/cli_runner.gen.go -package mocks gitlab.com/blender/flamenco-ng-poc/internal/worker CommandLineRunner