Documentation
¶
Overview ¶
File: internal/service/components.go
File: internal/service/factory.go
File: internal/service/initializers.go
Index ¶
- func InitializeKGClient(ctx context.Context, cfg config.KnowledgeGraphConfig, logger *zap.Logger, ...) (schemas.KnowledgeGraphClient, func(), error)
- func InitializeLLMClient(ctx context.Context, cfg config.AgentConfig, logger *zap.Logger) (schemas.LLMClient, error)
- func StartFindingsConsumer(ctx context.Context, wg *sync.WaitGroup, findingsChan <-chan schemas.Finding, ...)
- type ComponentFactory
- type Components
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeKGClient ¶
func InitializeKGClient(ctx context.Context, cfg config.KnowledgeGraphConfig, logger *zap.Logger, useInMemory bool) (schemas.KnowledgeGraphClient, func(), error)
InitializeKGClient connects to the database or starts an in-memory Knowledge Graph. This provides a centralized way to handle KG initialization, including fallbacks and standardized config. (Moved from cmd/evolution.go)
func InitializeLLMClient ¶
func InitializeLLMClient(ctx context.Context, cfg config.AgentConfig, logger *zap.Logger) (schemas.LLMClient, error)
InitializeLLMClient creates a new LLM client based on the configuration. This helper centralizes LLM initialization for commands like 'evolve' and 'self-heal'.
func StartFindingsConsumer ¶
func StartFindingsConsumer(ctx context.Context, wg *sync.WaitGroup, findingsChan <-chan schemas.Finding, dbStore schemas.Store, logger *zap.Logger)
StartFindingsConsumer launches a goroutine that reads from the findings channel and persists them using batching. It manages its lifecycle using the provided WaitGroup. Implements batching and robust draining on shutdown.
Types ¶
type ComponentFactory ¶
type ComponentFactory interface {
Create(ctx context.Context, cfg config.Interface, targets []string, logger *zap.Logger) (interface{}, error)
}
ComponentFactory defines the interface for creating the set of components needed for a scan. This abstraction is the key to making the scan command's logic testable. (Moved from cmd/factory.go) Returns interface{} to allow flexibility and avoid potential import cycles if mocks were in a separate package relying on this interface.
func NewComponentFactory ¶
func NewComponentFactory() ComponentFactory
NewComponentFactory creates a new production-ready component factory.
type Components ¶
type Components struct {
Store schemas.Store
BrowserManager schemas.BrowserManager
KnowledgeGraph schemas.KnowledgeGraphClient
TaskEngine schemas.TaskEngine
DiscoveryEngine schemas.DiscoveryEngine
Orchestrator schemas.Orchestrator
DBPool *pgxpool.Pool
// BrowserAllocatorCancel is the cancel function for the browser's root allocator context.
BrowserAllocatorCancel context.CancelFunc
// contains filtered or unexported fields
}
Components holds all the initialized services required for a scan. This struct centralizes the lifecycle management of scan-related dependencies. (Moved from cmd/factory.go)
func (*Components) Shutdown ¶
func (c *Components) Shutdown()
Shutdown gracefully closes all components within a hard timeout. This function is designed to be called via defer and handles its own timeout context to ensure cleanup happens even if the main scan context is abruptly canceled.