optracker

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceled = errors.New("operation canceled")

Functions

This section is empty.

Types

type OpTracker

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

func New

func New(w io.Writer, stream OutputStream) *OpTracker

func (*OpTracker) Add

func (t *OpTracker) Add(msg string, minStart time.Time) OperationID

Add creates a new item on the operations tracker returning the ID for that op. minStart is the time at which the tracker will start to show the task as in progress.

This function is safe to call on a Nil OpTracker and will no-op in that case

func (*OpTracker) AllDone

func (t *OpTracker) AllDone()

AllDone marks all ops as done. This function is safe to call on a Nil OpTracker and will no-op in that case

func (*OpTracker) Cancel added in v1.4.0

func (t *OpTracker) Cancel(id OperationID)

Cancel marks the operation as canceled. It is equivalent to t.Fail(id, ErrCanceled).

func (*OpTracker) Done

func (t *OpTracker) Done(id OperationID, minDuration time.Duration)

Done marks the given operation as done

This function is safe to call on a Nil OpTracker and will no-op in that case

func (*OpTracker) Fail

func (t *OpTracker) Fail(id OperationID, err error)

Fail marks the operation as failed with the given error

This function is safe to call on a Nil OpTracker and will no-op in that case

type OperationID

type OperationID int
const NoOperationID OperationID = -1

type OutputStream added in v1.11.0

type OutputStream interface {
	Send(*daemonpb.CommandMessage) error
}

Jump to

Keyboard shortcuts

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