Worker: move command_exe.go interface definitions

This commit is contained in:
Sybren A. Stüvel 2022-02-22 14:42:57 +01:00
parent 2a4db143e6
commit 9a5047a94d

View File

@ -32,18 +32,6 @@ import (
"gitlab.com/blender/flamenco-ng-poc/pkg/api" "gitlab.com/blender/flamenco-ng-poc/pkg/api"
) )
// Generate mock implementation of this interface.
//go:generate go run github.com/golang/mock/mockgen -destination mocks/command_listener.gen.go -package mocks gitlab.com/blender/flamenco-ng-poc/internal/worker CommandListener
// CommandListener sends the result of commands (log, output files) to the Manager.
type CommandListener interface {
// LogProduced sends any logging to whatever service for storing logging.
// logLines are concatenated.
LogProduced(ctx context.Context, taskID string, logLines ...string) error
// OutputProduced tells the Manager there has been some output (most commonly a rendered frame or video).
OutputProduced(ctx context.Context, taskID string, outputLocation string) error
}
type CommandExecutor struct { type CommandExecutor struct {
cli CommandLineRunner cli CommandLineRunner
listener CommandListener listener CommandListener
@ -57,6 +45,18 @@ var _ CommandRunner = (*CommandExecutor)(nil)
type commandCallable func(ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command) error type commandCallable func(ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command) error
// Generate mock implementation of this interface.
//go:generate go run github.com/golang/mock/mockgen -destination mocks/command_listener.gen.go -package mocks gitlab.com/blender/flamenco-ng-poc/internal/worker CommandListener
// CommandListener sends the result of commands (log, output files) to the Manager.
type CommandListener interface {
// LogProduced sends any logging to whatever service for storing logging.
// logLines are concatenated.
LogProduced(ctx context.Context, taskID string, logLines ...string) error
// OutputProduced tells the Manager there has been some output (most commonly a rendered frame or video).
OutputProduced(ctx context.Context, taskID string, outputLocation string) error
}
// TimeService is a service that operates on time. // TimeService is a service that operates on time.
type TimeService interface { type TimeService interface {
After(duration time.Duration) <-chan time.Time After(duration time.Duration) <-chan time.Time