Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportProgressFromArraySync ¶
func ReportProgressFromArraySync[T any](progress *inspectionmetadata.TaskProgressMetadata, source []T, process func(int, T) error) error
ReportProgressFromArraySync reports progress of processing an array synchronously. It updates the given TaskProgress with the current count and percentage. The process function is called for each element in the source array. If the process function returns an error, the reporting stops and the error is returned.
Types ¶
type IndeterminateUpdator ¶
type IndeterminateUpdator struct {
Progress *inspectionmetadata.TaskProgressMetadata
Interval time.Duration
// contains filtered or unexported fields
}
IndeterminateUpdator updates a progress bar for a task that cannot report its progress as a percentage. It shows a message with an animated indicator to signify that the task is running.
func NewIndeterminateUpdator ¶
func NewIndeterminateUpdator(progress *inspectionmetadata.TaskProgressMetadata, interval time.Duration) *IndeterminateUpdator
NewIndeterminateUpdator creates and initializes a new IndeterminateUpdator. It marks the associated TaskProgress as indeterminate.
func (*IndeterminateUpdator) Done ¶
func (i *IndeterminateUpdator) Done() error
Done stops updating progress bar. It returns an error if the updator is not yet started.
func (*IndeterminateUpdator) Start ¶
func (i *IndeterminateUpdator) Start(msg string) error
Start starts updating progress bar. It returns an error if the updator is already started.
type ProgressUpdator ¶
type ProgressUpdator struct {
Progress *inspectionmetadata.TaskProgressMetadata
Interval time.Duration
OnTick ProgressUpdatorOnTickFunc
// contains filtered or unexported fields
}
ProgressUpdator periodically updates a TaskProgress object at a specified interval. It uses a callback function to perform the update logic on each tick.
func NewProgressUpdator ¶
func NewProgressUpdator(progress *inspectionmetadata.TaskProgressMetadata, interval time.Duration, onTick ProgressUpdatorOnTickFunc) *ProgressUpdator
NewProgressUpdator creates and initializes a new ProgressUpdator.
func (*ProgressUpdator) Done ¶
func (p *ProgressUpdator) Done() error
Done stops the periodic updates. It returns an error if the updator was not started.
func (*ProgressUpdator) Start ¶
func (p *ProgressUpdator) Start(ctx context.Context) error
Start begins the periodic updates. It invokes the OnTick callback immediately and then continues to call it at the specified interval until Done is called. It returns an error if the updator has already been started.
type ProgressUpdatorOnTickFunc ¶
type ProgressUpdatorOnTickFunc = func(tp *inspectionmetadata.TaskProgressMetadata)
ProgressUpdatorOnTickFunc is a function type that is called by ProgressUpdator on each tick to update the task progress.