progressutil

package
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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 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.

Jump to

Keyboard shortcuts

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