Documentation
¶
Overview ¶
internal/engine/task_engine.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store interface {
PersistData(ctx context.Context, data *schemas.ResultEnvelope) error
}
Store defines the interface for any component that can persist task results. This decouples the engine from a specific storage implementation.
type TaskEngine ¶
type TaskEngine struct {
// contains filtered or unexported fields
}
TaskEngine manages the in-process distribution of tasks to a pool of workers.
func New ¶
func New( cfg config.Interface, logger *zap.Logger, storeService Store, worker Worker, globalCtx *core.GlobalContext, ) (*TaskEngine, error)
New creates a new TaskEngine. By accepting its dependencies (like the Worker) as interfaces, this function adheres to the Dependency Inversion Principle. The responsibility of creating concrete instances is moved to the application's composition root, making the engine more modular, decoupled, and easier to test.
func (*TaskEngine) Start ¶
func (e *TaskEngine) Start(ctx context.Context, taskChan <-chan schemas.Task)
Start launches the worker pool and begins consuming tasks from the provided channel. This method now correctly implements the schemas.TaskEngine interface.
func (*TaskEngine) Stop ¶
func (e *TaskEngine) Stop()
Stop gracefully shuts down the engine by waiting for all workers to finish.