progress

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, pf progressFunc) (string, error)

Run will run a writer and the progress function in parallel

func WithContextWriter

func WithContextWriter(ctx context.Context, writer Writer) context.Context

WithContextWriter adds the writer to the context

Types

type Event

type Event struct {
	ID         string
	ParentID   string
	Text       string
	Status     EventStatus
	StatusText string
	// contains filtered or unexported fields
}

Event represents a progress event.

func CreatedEvent

func CreatedEvent(ID string) Event

CreatedEvent creates a new Created (done) Event

func CreatingEvent

func CreatingEvent(ID string) Event

CreatingEvent creates a new Create in progress Event

func ErrorEvent

func ErrorEvent(ID string) Event

ErrorEvent creates a new Error Event

func ErrorMessageEvent

func ErrorMessageEvent(ID string, msg string) Event

ErrorMessageEvent creates a new Error Event with message

func KilledEvent

func KilledEvent(ID string) Event

KilledEvent creates a new Killed in progress Event

func KillingEvent

func KillingEvent(ID string) Event

KillingEvent creates a new Killing in progress Event

func NewEvent

func NewEvent(ID string, status EventStatus, statusText string) Event

NewEvent new event

func RemovedEvent

func RemovedEvent(ID string) Event

RemovedEvent creates a new removed (done) Event

func RemovingEvent

func RemovingEvent(ID string) Event

RemovingEvent creates a new Removing in progress Event

func RunningEvent

func RunningEvent(ID string) Event

RunningEvent creates a new Running in progress Event

func StartedEvent

func StartedEvent(ID string) Event

StartedEvent creates a new Started in progress Event

func StartingEvent

func StartingEvent(ID string) Event

StartingEvent creates a new Starting in progress Event

func StoppedEvent

func StoppedEvent(ID string) Event

StoppedEvent creates a new Stopping in progress Event

func StoppingEvent

func StoppingEvent(ID string) Event

StoppingEvent creates a new Stopping in progress Event

type EventStatus

type EventStatus int

EventStatus indicates the status of an action

const (
	// Working means that the current task is working
	Working EventStatus = iota
	// Done means that the current task is done
	Done
	// Error means that the current task has errored
	Error
)

type Writer

type Writer interface {
	Start(context.Context) error
	Stop()
	Event(Event)
}

Writer can write multiple progress events

func ContextWriter

func ContextWriter(ctx context.Context) Writer

ContextWriter returns the writer from the context

func NewWriter

func NewWriter(out console.File) (Writer, error)

NewWriter returns a new multi-progress writer

Jump to

Keyboard shortcuts

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