Help us shape the future of Go! Take the 2026 Go Developer Survey

progress

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProgressCallback

type ProgressCallback func(update ProgressUpdate)

ProgressCallback is called when progress is updated

type ProgressReporter

type ProgressReporter struct {
	// contains filtered or unexported fields
}

ProgressReporter manages and reports progress for long-running operations

func NewLaunchProgressReporter

func NewLaunchProgressReporter(instanceName string) *ProgressReporter

NewLaunchProgressReporter creates a progress reporter specifically for instance launches

func NewProgressReporter

func NewProgressReporter(operation string, stages []Stage) *ProgressReporter

NewProgressReporter creates a new progress reporter

func (*ProgressReporter) AddCallback

func (pr *ProgressReporter) AddCallback(callback ProgressCallback)

AddCallback adds a progress callback

func (*ProgressReporter) CompleteStage

func (pr *ProgressReporter) CompleteStage(stageName string) error

CompleteStage marks a stage as completed

func (*ProgressReporter) FailStage

func (pr *ProgressReporter) FailStage(stageName string, err error) error

FailStage marks a stage as failed

func (*ProgressReporter) GetProgress

func (pr *ProgressReporter) GetProgress() ProgressUpdate

GetProgress returns the current progress state

func (*ProgressReporter) ReportStageProgress

func (pr *ProgressReporter) ReportStageProgress(stageName string, progress float64, description ...string) error

ReportStageProgress updates progress for the current stage

func (*ProgressReporter) SetMetadata

func (pr *ProgressReporter) SetMetadata(key string, value any)

SetMetadata sets metadata for the operation

func (*ProgressReporter) StartStage

func (pr *ProgressReporter) StartStage(stageName string) error

StartStage marks a stage as started

type ProgressUpdate

type ProgressUpdate struct {
	Operation       string         `json:"operation"`
	CurrentStage    string         `json:"current_stage"`
	StageProgress   float64        `json:"stage_progress"`
	OverallProgress float64        `json:"overall_progress"`
	ETA             *time.Duration `json:"eta,omitempty"`
	ElapsedTime     time.Duration  `json:"elapsed_time"`
	Description     string         `json:"description"`
	Metadata        map[string]any `json:"metadata,omitempty"`
	AllStages       []Stage        `json:"all_stages"`
}

ProgressUpdate contains information about current progress

type Stage

type Stage struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Weight      float64     `json:"weight"` // Relative weight for ETA calculation (0.0-1.0)
	Status      StageStatus `json:"status"`
	Progress    float64     `json:"progress"` // Progress within this stage (0.0-1.0)
	StartTime   *time.Time  `json:"start_time,omitempty"`
	EndTime     *time.Time  `json:"end_time,omitempty"`
	Error       string      `json:"error,omitempty"`
}

Stage represents a step in a multi-stage operation

type StageStatus

type StageStatus string

StageStatus represents the status of a stage

const (
	StagePending    StageStatus = "pending"
	StageInProgress StageStatus = "in_progress"
	StageCompleted  StageStatus = "completed"
	StageFailed     StageStatus = "failed"
	StageSkipped    StageStatus = "skipped"
)

Jump to

Keyboard shortcuts

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