Documentation
¶
Overview ¶
Package progress provides progress reporting for DevSec operations.
Index ¶
- type ChannelReporter
- func (r *ChannelReporter) Close()
- func (r *ChannelReporter) ReportCompleted(result any, err error)
- func (r *ChannelReporter) ReportFinding(finding model.Finding)
- func (r *ChannelReporter) ReportFindingCount(count FindingCount)
- func (r *ChannelReporter) ReportLog(level, message string)
- func (r *ChannelReporter) ReportStageCompleted(name string, status StageStatus, duration time.Duration)
- func (r *ChannelReporter) ReportStageProgress(name string, progress float64)
- func (r *ChannelReporter) ReportStageStarted(name string)
- type Event
- type EventType
- type FindingCount
- type NoopReporter
- func (r *NoopReporter) Close()
- func (r *NoopReporter) ReportCompleted(_ any, _ error)
- func (r *NoopReporter) ReportFinding(_ model.Finding)
- func (r *NoopReporter) ReportFindingCount(_ FindingCount)
- func (r *NoopReporter) ReportLog(_, _ string)
- func (r *NoopReporter) ReportStageCompleted(_ string, _ StageStatus, _ time.Duration)
- func (r *NoopReporter) ReportStageProgress(_ string, _ float64)
- func (r *NoopReporter) ReportStageStarted(_ string)
- type Reporter
- type StageStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelReporter ¶
type ChannelReporter struct {
// contains filtered or unexported fields
}
ChannelReporter sends progress events through a channel.
func NewChannelReporter ¶
func NewChannelReporter(bufferSize int) (reporter *ChannelReporter, events <-chan Event)
NewChannelReporter creates a new ChannelReporter with the given buffer size. Returns the reporter and a read-only channel for receiving events.
func (*ChannelReporter) Close ¶
func (r *ChannelReporter) Close()
Close closes the reporter and its channel.
func (*ChannelReporter) ReportCompleted ¶
func (r *ChannelReporter) ReportCompleted(result any, err error)
ReportCompleted reports that the operation has completed.
func (*ChannelReporter) ReportFinding ¶
func (r *ChannelReporter) ReportFinding(finding model.Finding)
ReportFinding reports a discovered finding.
func (*ChannelReporter) ReportFindingCount ¶
func (r *ChannelReporter) ReportFindingCount(count FindingCount)
ReportFindingCount reports the current finding counts.
func (*ChannelReporter) ReportLog ¶
func (r *ChannelReporter) ReportLog(level, message string)
ReportLog reports a log message.
func (*ChannelReporter) ReportStageCompleted ¶
func (r *ChannelReporter) ReportStageCompleted(name string, status StageStatus, duration time.Duration)
ReportStageCompleted reports that a stage has completed.
func (*ChannelReporter) ReportStageProgress ¶
func (r *ChannelReporter) ReportStageProgress(name string, progress float64)
ReportStageProgress reports progress within a stage.
func (*ChannelReporter) ReportStageStarted ¶
func (r *ChannelReporter) ReportStageStarted(name string)
ReportStageStarted reports that a stage has started.
type Event ¶
type Event struct {
Timestamp time.Time
Result any
Error error
Finding *model.Finding
StageName string
LogLevel string
LogMessage string
FindingCount FindingCount
Duration time.Duration
Progress float64
Type EventType
StageStatus StageStatus
}
Event represents a progress update event.
type EventType ¶
type EventType int
EventType represents the type of progress event.
const ( // EventStageStarted indicates a stage has started. EventStageStarted EventType = iota // EventStageProgress indicates progress within a stage. EventStageProgress // EventStageCompleted indicates a stage has completed. EventStageCompleted // EventFindingDiscovered indicates a finding was discovered. EventFindingDiscovered // EventLogMessage indicates a log message. EventLogMessage // EventPipelineCompleted indicates the pipeline has completed. EventPipelineCompleted )
type FindingCount ¶
FindingCount holds counts of findings by severity.
func (FindingCount) Total ¶
func (fc FindingCount) Total() int
Total returns the total number of findings.
type NoopReporter ¶
type NoopReporter struct{}
NoopReporter is a no-op implementation of Reporter. Used when TUI progress display is disabled.
func NewNoopReporter ¶
func NewNoopReporter() *NoopReporter
NewNoopReporter creates a new NoopReporter.
func (*NoopReporter) ReportCompleted ¶
func (r *NoopReporter) ReportCompleted(_ any, _ error)
ReportCompleted is a no-op.
func (*NoopReporter) ReportFinding ¶
func (r *NoopReporter) ReportFinding(_ model.Finding)
ReportFinding is a no-op.
func (*NoopReporter) ReportFindingCount ¶
func (r *NoopReporter) ReportFindingCount(_ FindingCount)
ReportFindingCount is a no-op.
func (*NoopReporter) ReportLog ¶
func (r *NoopReporter) ReportLog(_, _ string)
ReportLog is a no-op.
func (*NoopReporter) ReportStageCompleted ¶
func (r *NoopReporter) ReportStageCompleted(_ string, _ StageStatus, _ time.Duration)
ReportStageCompleted is a no-op.
func (*NoopReporter) ReportStageProgress ¶
func (r *NoopReporter) ReportStageProgress(_ string, _ float64)
ReportStageProgress is a no-op.
func (*NoopReporter) ReportStageStarted ¶
func (r *NoopReporter) ReportStageStarted(_ string)
ReportStageStarted is a no-op.
type Reporter ¶
type Reporter interface {
// ReportStageStarted reports that a stage has started.
ReportStageStarted(name string)
// ReportStageProgress reports progress within a stage (0.0 to 1.0).
ReportStageProgress(name string, progress float64)
// ReportStageCompleted reports that a stage has completed.
ReportStageCompleted(name string, status StageStatus, duration time.Duration)
// ReportFinding reports a discovered finding.
ReportFinding(finding model.Finding)
// ReportFindingCount reports the current finding counts.
ReportFindingCount(count FindingCount)
// ReportLog reports a log message.
ReportLog(level, message string)
// ReportCompleted reports that the operation has completed.
ReportCompleted(result any, err error)
// Close closes the reporter.
Close()
}
Reporter defines the interface for reporting progress.
type StageStatus ¶
type StageStatus int
StageStatus represents the status of a pipeline stage.
const ( // StatusPending indicates the stage is waiting to run. StatusPending StageStatus = iota // StatusRunning indicates the stage is currently running. StatusRunning // StatusSuccess indicates the stage completed successfully. StatusSuccess // StatusFailed indicates the stage failed. StatusFailed // StatusSkipped indicates the stage was skipped. StatusSkipped )