progress

package
v0.15.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableMonitors

func AvailableMonitors() []string

AvailableMonitors returns the list of schemes that have been registered with `MonitorInitializeFunc` functions.

func RegisterMonitor

func RegisterMonitor(ctx context.Context, name string, fn MonitorInitializeFunc) error

RegisterMonitor associates a URI scheme with a `MonitorInitializeFunc` initialization function.

Types

type Event

type Event struct {
	// The total number of pages being processed
	Pages int
	// The current page being processed
	Page int
	// An optional string describing the event
	Message string
}

Event defines details about a (picturebook) page being processed.

func NewEvent

func NewEvent(page int, count int) *Event

NewEvent returns a new `Event` instance derived from 'page' and 'count'.

type Monitor

type Monitor interface {
	// Signal() dispatches a processing event to report.
	Signal(context.Context, *Event) error
	// Clear() resets the progress reporting interface.
	Clear() error
	// Close() terminates the progress reporter.
	Close() error
}

Monitor provides an interface for reporting the progress of a picturebook creation process.

func NewMonitor

func NewMonitor(ctx context.Context, uri string) (Monitor, error)

NewMonitor returns a new `Monitor` instance for 'uri' whose scheme is expected to have been associated with an `MonitorInitializeFunc` (by the `RegisterMonitor` method.

func NewNullMonitor

func NewNullMonitor(ctx context.Context, uri string) (Monitor, error)

NewNullMonitor returns a new `NullMonitor` instance implementing the `Monitor` interface.

func NewProgressBarMonitor

func NewProgressBarMonitor(ctx context.Context, uri string) (Monitor, error)

NewProgressBarMonitor returns a new `ProgressBarMonitor` instance implementing the `Monitor` interface.

type MonitorInitializeFunc

type MonitorInitializeFunc func(context.Context, string) (Monitor, error)

type MonitorInitializeFunc defined a common initialization function for instances implementing the Monitor interface. This is specified when the packages definining those instances call `RegisterMonitor` and invoked with the `NewMonitor` method is called.

type NullMonitor

type NullMonitor struct {
	Monitor
}

NullMonitor implements the `Monitor` interface for receiving progress reports but not doing anything with them.

func (*NullMonitor) Clear

func (m *NullMonitor) Clear() error

Clear doesn't do anything.

func (*NullMonitor) Close

func (m *NullMonitor) Close() error

Close doesn't do anything.

func (*NullMonitor) Signal

func (m *NullMonitor) Signal(ctx context.Context, ev *Event) error

Signal receives 'ev' but doesn't do anything with it.

type ProgressBarMonitor

type ProgressBarMonitor struct {
	Monitor
	// contains filtered or unexported fields
}

ProgressBarMonitor implements the `Monitor` interface for receiving progress reports using the `schollz/progressbar/v3` package.

func (*ProgressBarMonitor) Clear

func (m *ProgressBarMonitor) Clear() error

Clear removes the current progress bar.

func (*ProgressBarMonitor) Close

func (m *ProgressBarMonitor) Close() error

Close terminates the progress bar.

func (*ProgressBarMonitor) Signal

func (m *ProgressBarMonitor) Signal(ctx context.Context, ev *Event) error

Signal updates the progress bar with details from 'ev'.

Jump to

Keyboard shortcuts

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