engine

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 9 Imported by: 0

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.

type Worker

type Worker interface {
	ProcessTask(ctx context.Context, analysisCtx *core.AnalysisContext) error
}

Worker defines the interface for any component that can process a task. This allows us to easily swap in different worker implementations or mocks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL