Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewCSVWriter creates a new CSV writer for the specified file path
func (*CSVWriter) WriteResult ¶
WriteResult writes a single scan result to the CSV file