progress

package
v0.0.0-...-05f81da Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(pi Client)

Set defines the default progress client implementation

Types

type BaseProgress

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

BaseProgress is the common implementation between MultiStep and Loop progress

func (*BaseProgress) Failure

func (prg *BaseProgress) Failure()

Failure is the common BaseProgress implementation and simply notify the actual implementation we've finished a task unsuccessfully

func (*BaseProgress) Partial

func (prg *BaseProgress) Partial(step int)

Partial notifies the actual implementation we've moved one step on the set of steps for the MultiStep progress implementation

func (*BaseProgress) Success

func (prg *BaseProgress) Success()

Success is the common BaseProgress implementation and simply notify the actual implementation we've finished a task successfully

type Client

type Client interface {
	// Desc is called when a new progress unit is started
	Desc(desc string)

	// Partial is called on behalf of a MultiStep progress task - it's called for each
	// partial step completion
	Partial(total int, step int)

	// Step is called on behalf of a Loop progress task - it's called based on the
	// time returned by LoopWaitDuration
	Step()

	// Success is called whenever a progress task is completed successfully
	Success()

	// Failure is called whenever a progress task is failed to be completed
	Failure()

	// LoopWaitDuration gives the implementation the opportunity configure the loop progress
	// step period
	LoopWaitDuration() time.Duration
}

Client is the interface a frontend must implement in order to be notified about the install progress

type Loop

type Loop struct {
	BaseProgress
	// contains filtered or unexported fields
}

Loop defines the specific data for Loop progress implementation

func (*Loop) Failure

func (prg *Loop) Failure()

Failure notifies the actual implementation we have finished a task unsuccessfully, this is the specific implementation for Loop based progress

func (*Loop) Success

func (prg *Loop) Success()

Success notifies the actual implementation we have finished a task successfully, this is the specific implementation for Loop based progress

type Progress

type Progress interface {
	Partial(step int)
	Success()
	Failure()
}

Progress is the internal interface for the progress subsystem, currently we have two different implementations a MultiStep and a Loop based one

func MultiStep

func MultiStep(total int, format string, a ...interface{}) Progress

MultiStep creates a new MultiStep implementation

func NewLoop

func NewLoop(format string, a ...interface{}) Progress

NewLoop creates a new Loop based progress implementation

Jump to

Keyboard shortcuts

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