Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunWithProgress ¶
func RunWithProgress[T comparable, R any]( observer func(T), f func(*Progress[T]) (R, error), ) (R, error)
RunWithProgress runs a function with a background goroutine reporting and progress to an observer.
func RunWithProgressE ¶
func RunWithProgressE[T comparable]( observer func(T), f func(*Progress[T]) error, ) error
RunWithProgressE runs a function with a background goroutine reporting and progress to an observer.
Types ¶
type Progress ¶
type Progress[T comparable] struct { // contains filtered or unexported fields }
Progress is a wrapper around a channel which can be used to report progress of an operation. The zero value of Progress is invalid. Use NewProgress to create a new instance.
func NewProgress ¶
func NewProgress[T comparable]() *Progress[T]
NewProgress creates a new instance of Progress.
func (*Progress[T]) Done ¶
func (p *Progress[T]) Done()
Done closes the underlying channel, signaling no more progress will be reported. It is an error to call SetProgress after calling Done.
func (*Progress[T]) Progress ¶
func (p *Progress[T]) Progress() <-chan T
Progress returns the read side of the underlying channel. The channel will be closed when [Done] is called, so a `range` loop may be used to consume all progress updates.
func (*Progress[T]) SetProgress ¶
func (p *Progress[T]) SetProgress(progress T)
SetProgress reports progress to the channel.