Documentation
¶
Overview ¶
Package workers provides a worker pool implementation for concurrent operations in scanorama. It supports job queuing, rate limiting, graceful shutdown, and integrates with the structured logging and metrics systems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Size is the number of worker goroutines to create.
Size int
// QueueSize is the maximum number of jobs that can be queued.
QueueSize int
// MaxRetries is the maximum number of retries for failed jobs.
MaxRetries int
// RetryDelay is the delay between retries.
RetryDelay time.Duration
// ShutdownTimeout is the maximum time to wait for workers to finish.
ShutdownTimeout time.Duration
// RateLimit is the maximum number of jobs per second (0 = no limit).
RateLimit int
}
Config holds configuration for the worker pool.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default worker pool configuration.
type DiscoveryJob ¶
type DiscoveryJob struct {
// contains filtered or unexported fields
}
DiscoveryJob implements Job interface for discovery operations.
func NewDiscoveryJob ¶
func NewDiscoveryJob(id, network, method string, executor func(ctx context.Context, network, method string) error) *DiscoveryJob
NewDiscoveryJob creates a new discovery job.
type Job ¶
type Job interface {
// Execute performs the job and returns an error if it fails.
Execute(ctx context.Context) error
// ID returns a unique identifier for the job.
ID() string
// Type returns the job type for metrics and logging.
Type() string
}
Job represents a unit of work to be executed by a worker.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a pool of worker goroutines for concurrent job execution.
type ScanJob ¶
type ScanJob struct {
// contains filtered or unexported fields
}
ScanJob implements Job interface for scan operations.
func NewScanJob ¶
func NewScanJob(id, target, ports, scanType string, executor func(ctx context.Context, target, ports, scanType string) error) *ScanJob
NewScanJob creates a new scan job.