progress

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

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 added in v1.0.4

func CreatedEvent(ID string) Event

CreatedEvent creates a new Created (done) Event

func CreatingEvent added in v1.0.4

func CreatingEvent(ID string) Event

CreatingEvent creates a new Create in progress Event

func ErrorEvent added in v1.0.4

func ErrorEvent(ID string) Event

ErrorEvent creates a new Error Event

func ErrorMessageEvent added in v1.0.4

func ErrorMessageEvent(ID string, msg string) Event

ErrorMessageEvent creates a new Error Event with message

func NewEvent added in v1.0.4

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

NewEvent new event

func RemovedEvent added in v1.0.4

func RemovedEvent(ID string) Event

RemovedEvent creates a new removed (done) Event

func RemovingEvent added in v1.0.4

func RemovingEvent(ID string) Event

RemovingEvent creates a new Removing in progress Event

func RunningEvent added in v1.0.4

func RunningEvent(ID string) Event

RunningEvent creates a new Running in progress Event

func StartedEvent added in v1.0.4

func StartedEvent(ID string) Event

StartedEvent creates a new Started in progress Event

func StartingEvent added in v1.0.4

func StartingEvent(ID string) Event

StartingEvent creates a new Starting in progress Event

func StoppingEvent added in v1.0.4

func StoppingEvent(ID string) Event

StoppingEvent stops a new Removing 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