output

package
v0.15.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBatchWriterStopped = NewBatchWriterError("batch writer is stopped")
	ErrBatchWriteFailed   = NewBatchWriterError("batch write operation failed")
)

Error definitions

Functions

This section is empty.

Types

type BatchWriter

type BatchWriter struct {
	// contains filtered or unexported fields
}

BatchWriter handles time-based batch writing of scan results to CSV

func NewBatchWriter

func NewBatchWriter(csvWriter *CSVWriter, scanContext *pkg.ScanContext, config BatchWriterConfig) *BatchWriter

NewBatchWriter creates a new batch writer with the specified CSV writer and configuration

func (*BatchWriter) Flush

func (bw *BatchWriter) Flush() error

Flush forces an immediate flush of all buffered results

func (*BatchWriter) GetStats

func (bw *BatchWriter) GetStats() BatchWriterStats

GetStats returns current statistics about the batch writer

func (*BatchWriter) Start

func (bw *BatchWriter) Start() error

Start begins the batch writing process

func (*BatchWriter) Stop

func (bw *BatchWriter) Stop() error

Stop stops the batch writer and flushes any remaining data

func (*BatchWriter) WriteResult

func (bw *BatchWriter) WriteResult(result CSVResult) error

WriteResult adds a result to the buffer for batch writing

type BatchWriterConfig

type BatchWriterConfig struct {
	FlushInterval time.Duration // How often to flush buffered results
	MaxBufferSize int           // Maximum number of results to buffer before forced flush
}

BatchWriterConfig contains configuration for the batch writer

func DefaultBatchWriterConfig

func DefaultBatchWriterConfig() BatchWriterConfig

DefaultBatchWriterConfig returns a default configuration

type BatchWriterError

type BatchWriterError struct {
	// contains filtered or unexported fields
}

BatchWriterError represents an error from the batch writer

func NewBatchWriterError

func NewBatchWriterError(message string) *BatchWriterError

func (*BatchWriterError) Error

func (e *BatchWriterError) Error() string

type BatchWriterStats

type BatchWriterStats struct {
	BufferSize     int
	MaxBufferSize  int
	TotalWritten   int
	BatchesWritten int
	LastFlushTime  time.Time
	FlushInterval  time.Duration
	IsStarted      bool
	IsStopped      bool
	TimeSinceFlush time.Duration
}

BatchWriterStats provides statistics about the batch writer

type CSVResult

type CSVResult struct {
	Timestamp    time.Time `json:"timestamp"`
	ScanID       string    `json:"scan_id"`
	Protocol     string    `json:"protocol"`
	Host         string    `json:"host"`
	Port         int       `json:"port"`
	Status       string    `json:"status"`
	ResponseTime string    `json:"response_time"`
	ErrorMessage string    `json:"error_message"`
}

CSVResult represents a single scan result for CSV output

type CSVWriter

type CSVWriter struct {
	// contains filtered or unexported fields
}

CSVWriter handles thread-safe CSV file writing with buffering

func NewCSVWriter

func NewCSVWriter(filePath string) (*CSVWriter, error)

NewCSVWriter creates a new CSV writer for the specified file path

func (*CSVWriter) Close

func (w *CSVWriter) Close() error

Close closes the CSV writer and flushes remaining data

func (*CSVWriter) Flush

func (w *CSVWriter) Flush() error

Flush flushes any buffered data to disk

func (*CSVWriter) GetPath

func (w *CSVWriter) GetPath() string

GetPath returns the file path of the CSV writer

func (*CSVWriter) IsClosed

func (w *CSVWriter) IsClosed() bool

IsClosed returns whether the writer is closed

func (*CSVWriter) WriteResult

func (w *CSVWriter) WriteResult(result CSVResult) error

WriteResult writes a single scan result to the CSV file

Jump to

Keyboard shortcuts

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