progrock

package module
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 37 Imported by: 10

README

progrock Go Reference

progress UI that rocks

Progrock is a toolkit for streaming, recording, and displaying concurrent progress of inter-dependent vertexes in an execution graph.

Here's how it looks (from Bass):

https://github.com/vito/bass/assets/1880/ab05445c-95f7-44b6-a67b-d9fc8eb02d41

usage

thanks

This repository originally housed code extracted directly from Buildkit, though it has since been reimplemented from scratch with only the protocol bearing any resemblance.

Documentation

Index

Constants

View Source
const (
	ProgressService_WriteUpdates_FullMethodName = "/progrock.ProgressService/WriteUpdates"
)
View Source
const RootGroup = ""

RootGroup is the name of the outermost group.

Its value is blank, since it should never really be shown in the UI, since there isn't really a name that would make sense in all contexts. Instead the Root group should just be given special treatment, in whatever way makes sense to the user - for example, by only displaying its contents, as if each of its children were at the top level.

View Source
const RootID = "_root"

RootID is "_root", the static ID value set for all Root groups.

Note: all Root groups MUST have the same ID, so that there are never "multiple roots" - a truly unsettling concept.

Variables

View Source
var (
	LogStream_name = map[int32]string{
		0: "STDIN",
		1: "STDOUT",
		2: "STDERR",
	}
	LogStream_value = map[string]int32{
		"STDIN":  0,
		"STDOUT": 1,
		"STDERR": 2,
	}
)

Enum value maps for LogStream.

View Source
var (
	MessageLevel_name = map[int32]string{
		0:  "INVALID",
		-4: "DEBUG",
		4:  "WARNING",
		8:  "ERROR",
	}
	MessageLevel_value = map[string]int32{
		"INVALID": 0,
		"DEBUG":   -4,
		"WARNING": 4,
		"ERROR":   8,
	}
)

Enum value maps for MessageLevel.

Clock is used to determine the current time.

View Source
var File_progress_proto protoreflect.FileDescriptor
View Source
var ProgressService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "progrock.ProgressService",
	HandlerType: (*ProgressServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "WriteUpdates",
			Handler:       _ProgressService_WriteUpdates_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "progress.proto",
}

ProgressService_ServiceDesc is the grpc.ServiceDesc for ProgressService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func Pipe

func Pipe() (Reader, Writer)

func RecorderToContext deprecated

func RecorderToContext(ctx context.Context, recorder *Recorder) context.Context

RecorderToContext returns a new context with the given Recorder attached.

Deprecated: use ToContext instead.

func RegisterProgressServiceServer added in v0.5.0

func RegisterProgressServiceServer(s grpc.ServiceRegistrar, srv ProgressServiceServer)

func ToContext added in v0.10.0

func ToContext(ctx context.Context, recorder *Recorder) context.Context

ToContext returns a new context with the given Recorder attached.

func WriteMessage added in v0.9.0

func WriteMessage(out *termenv.Output, msg *Message) error

Types

type Discard

type Discard struct{}

func (Discard) Close

func (Discard) Close() error

func (Discard) WriteStatus

func (Discard) WriteStatus(*StatusUpdate) error

type Group

type Group struct {

	// ID is an arbitrary identifier for the group.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Parent is the ID of a parent group.
	Parent *string `protobuf:"bytes,2,opt,name=parent,proto3,oneof" json:"parent,omitempty"`
	// Name is a name for this group, relative to its parent.
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	// Labels contains a series of name/value pairs.
	Labels []*Label `protobuf:"bytes,4,rep,name=labels,proto3" json:"labels,omitempty"`
	// Started is the timestamp that the group started.
	Started *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=started,proto3" json:"started,omitempty"`
	// Completed is the timestamp that the group completed.
	Completed *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=completed,proto3,oneof" json:"completed,omitempty"`
	// Weak indicates that the group should not be considered equal to non-weak
	// groups. Weak groups may be used to group together vertexes that correspond
	// to a single API (e.g. a Dockerfile build), as opposed to "strong" groups
	// explicitly configured by the user (e.g. "test", "build", etc).
	Weak bool `protobuf:"varint,7,opt,name=weak,proto3" json:"weak,omitempty"`
	// contains filtered or unexported fields
}

Group is used to group related vertexes.

func (*Group) Descriptor deprecated

func (*Group) Descriptor() ([]byte, []int)

Deprecated: Use Group.ProtoReflect.Descriptor instead.

func (*Group) GetCompleted

func (x *Group) GetCompleted() *timestamppb.Timestamp

func (*Group) GetId

func (x *Group) GetId() string

func (*Group) GetLabels

func (x *Group) GetLabels() []*Label

func (*Group) GetName

func (x *Group) GetName() string

func (*Group) GetParent

func (x *Group) GetParent() string

func (*Group) GetStarted

func (x *Group) GetStarted() *timestamppb.Timestamp

func (*Group) GetWeak added in v0.4.0

func (x *Group) GetWeak() bool

func (*Group) ProtoMessage

func (*Group) ProtoMessage()

func (*Group) ProtoReflect

func (x *Group) ProtoReflect() protoreflect.Message

func (*Group) Reset

func (x *Group) Reset()

func (*Group) String

func (x *Group) String() string

type GroupOpt added in v0.4.0

type GroupOpt func(*Group)

GroupOpt is an option for creating a Group.

func Weak added in v0.4.0

func Weak() GroupOpt

Weak indicates that the group should not be considered equal to non-weak groups. Weak groups may be used to group together vertexes that correspond to a single API (e.g. a Dockerfile build), as opposed to "strong" groups explicitly configured by the user (e.g. "test", "build", etc).

func WithGroupID added in v0.4.0

func WithGroupID(id string) GroupOpt

WithGroupID sets the ID for the group. An ID should be globally unique. If not specified, the ID defaults to the group's name with the group's start time appended.

func WithLabels added in v0.4.0

func WithLabels(labels ...*Label) GroupOpt

WithLabels sets labels on the group.

func WithStarted added in v0.4.0

func WithStarted(started time.Time) GroupOpt

WithStarted sets the start time of the group.

type Label

type Label struct {

	// Name is the name of the label.
	//
	// Domain prefixes are a convention for disambiguation, such as
	// progrock.io/foo.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Value is the value of the label.
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

Label is a name/value pair used for annotation.

func ErrorLabel added in v0.9.0

func ErrorLabel(err error) *Label

ErrorLabel is shorthand for Labelf("error", "%s", err).

func Labelf added in v0.9.0

func Labelf(name string, format string, vals ...any) *Label

Labelf is a convenience function for creating a Label from a format string and values.

If no values are given, format is used verbatim, so Labelf also doubles as a plain string value Label constructor.

func (*Label) Descriptor deprecated

func (*Label) Descriptor() ([]byte, []int)

Deprecated: Use Label.ProtoReflect.Descriptor instead.

func (*Label) GetName

func (x *Label) GetName() string

func (*Label) GetValue

func (x *Label) GetValue() string

func (*Label) MessageOpt added in v0.9.0

func (l *Label) MessageOpt(m *Message)

MessageOpt adds the Label to the Message's labels.

func (*Label) ProtoMessage

func (*Label) ProtoMessage()

func (*Label) ProtoReflect

func (x *Label) ProtoReflect() protoreflect.Message

func (*Label) Reset

func (x *Label) Reset()

func (*Label) String

func (x *Label) String() string

type LogStream

type LogStream int32

LogStream is the standard stream that a log message was emitted to.

const (
	// STDIN is /dev/stdin.
	LogStream_STDIN LogStream = 0
	// STDOUT is /dev/stdout.
	LogStream_STDOUT LogStream = 1
	// STDOUT is /dev/stderr.
	LogStream_STDERR LogStream = 2
)

func (LogStream) Descriptor

func (LogStream) Descriptor() protoreflect.EnumDescriptor

func (LogStream) Enum

func (x LogStream) Enum() *LogStream

func (LogStream) EnumDescriptor deprecated

func (LogStream) EnumDescriptor() ([]byte, []int)

Deprecated: Use LogStream.Descriptor instead.

func (LogStream) Number

func (x LogStream) Number() protoreflect.EnumNumber

func (LogStream) String

func (x LogStream) String() string

func (LogStream) Type

type Membership added in v0.2.0

type Membership struct {

	// Group is the ID of the group.
	Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"`
	// Vertexes is the set of vertex IDs that are members of the group.
	Vertexes []string `protobuf:"bytes,2,rep,name=vertexes,proto3" json:"vertexes,omitempty"`
	// contains filtered or unexported fields
}

Membership declares a set of vertexes to be members of a group.

func (*Membership) Descriptor deprecated added in v0.2.0

func (*Membership) Descriptor() ([]byte, []int)

Deprecated: Use Membership.ProtoReflect.Descriptor instead.

func (*Membership) GetGroup added in v0.2.0

func (x *Membership) GetGroup() string

func (*Membership) GetVertexes added in v0.2.0

func (x *Membership) GetVertexes() []string

func (*Membership) ProtoMessage added in v0.2.0

func (*Membership) ProtoMessage()

func (*Membership) ProtoReflect added in v0.2.0

func (x *Membership) ProtoReflect() protoreflect.Message

func (*Membership) Reset added in v0.2.0

func (x *Membership) Reset()

func (*Membership) String added in v0.2.0

func (x *Membership) String() string

type Message added in v0.8.0

type Message struct {

	// Message is the human-readable content of the message.
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// Level indicates the severity of the message.
	Level MessageLevel `protobuf:"varint,2,opt,name=level,proto3,enum=progrock.MessageLevel" json:"level,omitempty"`
	// Code is an optional machine-readable name for the message, such as an
	// error code. It may be included for i10n.
	Code *string `protobuf:"bytes,3,opt,name=code,proto3,oneof" json:"code,omitempty"`
	// Labels contains a series of name/value pairs.
	Labels []*Label `protobuf:"bytes,4,rep,name=labels,proto3" json:"labels,omitempty"`
	// contains filtered or unexported fields
}

Message is a message to display to the user at a global level.

func (*Message) Descriptor deprecated added in v0.8.0

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetCode added in v0.8.0

func (x *Message) GetCode() string

func (*Message) GetLabels added in v0.8.0

func (x *Message) GetLabels() []*Label

func (*Message) GetLevel added in v0.8.0

func (x *Message) GetLevel() MessageLevel

func (*Message) GetMessage added in v0.8.0

func (x *Message) GetMessage() string

func (*Message) ProtoMessage added in v0.8.0

func (*Message) ProtoMessage()

func (*Message) ProtoReflect added in v0.8.0

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset added in v0.8.0

func (x *Message) Reset()

func (*Message) String added in v0.8.0

func (x *Message) String() string

type MessageLevel added in v0.8.0

type MessageLevel int32

MessageLevel indicates the severity of a message.

Note that there isn't an INFO level as Messages aren't meant to be used for general-purpose logging or updates; those should go through the regular vertex status update flow instead. Nevertheless, room has been left for more levels in the future, and the enum values are aligned with Go's log/slog package.

const (
	// INVALID is not a valid message level. Protobuf requires the first enum
	// value to be 0, so here we are.
	//
	// In the future this _may_ become INFO, which would match Go's log/slog
	// package convention, but no promises!
	MessageLevel_INVALID MessageLevel = 0
	// DEBUG indicates that the message should only be shown if debugging is
	// enabled.
	MessageLevel_DEBUG MessageLevel = -4
	// WARNING indicates that the message should be shown to the user at all
	// times, but that execution of the program can continue as normal.
	MessageLevel_WARNING MessageLevel = 4
	// ERROR indicates that the message should be shown to the user, and that
	// executation of the program cannot continue.
	MessageLevel_ERROR MessageLevel = 8
)

func (MessageLevel) Descriptor added in v0.8.0

func (MessageLevel) Enum added in v0.8.0

func (x MessageLevel) Enum() *MessageLevel

func (MessageLevel) EnumDescriptor deprecated added in v0.8.0

func (MessageLevel) EnumDescriptor() ([]byte, []int)

Deprecated: Use MessageLevel.Descriptor instead.

func (MessageLevel) Number added in v0.8.0

func (MessageLevel) String added in v0.8.0

func (x MessageLevel) String() string

func (MessageLevel) Type added in v0.8.0

type MessageOpt added in v0.8.0

type MessageOpt interface {
	MessageOpt(*Message)
}

MessageOpt is an option for creating a Message.

func WithMessageCode added in v0.8.0

func WithMessageCode(code string) MessageOpt

WithMessageCode sets the message code.

func WithMessageLabels added in v0.8.0

func WithMessageLabels(labels ...*Label) MessageOpt

WithMessageLabels sets the message labels.

func WithMessageLevel added in v0.8.0

func WithMessageLevel(level MessageLevel) MessageOpt

WithMessageLevel sets the message level.

type Model

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

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Print

func (m *Model) Print(w io.Writer)

func (*Model) PrintTrailer added in v0.6.0

func (m *Model) PrintTrailer(w io.Writer)

func (*Model) SetStatusInfo added in v0.10.0

func (m *Model) SetStatusInfo(info StatusInfo)

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() string

type MultiWriter

type MultiWriter []Writer

func (MultiWriter) Close

func (mw MultiWriter) Close() error

func (MultiWriter) WriteStatus

func (mw MultiWriter) WriteStatus(v *StatusUpdate) error

type ProgressServiceClient added in v0.5.0

type ProgressServiceClient interface {
	WriteUpdates(ctx context.Context, opts ...grpc.CallOption) (ProgressService_WriteUpdatesClient, error)
}

ProgressServiceClient is the client API for ProgressService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewProgressServiceClient added in v0.5.0

func NewProgressServiceClient(cc grpc.ClientConnInterface) ProgressServiceClient

type ProgressServiceServer added in v0.5.0

type ProgressServiceServer interface {
	WriteUpdates(ProgressService_WriteUpdatesServer) error
	// contains filtered or unexported methods
}

ProgressServiceServer is the server API for ProgressService service. All implementations must embed UnimplementedProgressServiceServer for forward compatibility

type ProgressService_WriteUpdatesClient added in v0.5.0

type ProgressService_WriteUpdatesClient interface {
	Send(*StatusUpdate) error
	CloseAndRecv() (*emptypb.Empty, error)
	grpc.ClientStream
}

type ProgressService_WriteUpdatesServer added in v0.5.0

type ProgressService_WriteUpdatesServer interface {
	SendAndClose(*emptypb.Empty) error
	Recv() (*StatusUpdate, error)
	grpc.ServerStream
}

type RPCReceiver

type RPCReceiver struct {
	UnimplementedProgressServiceServer
	// contains filtered or unexported fields
}

RPCReceiver is a ProgressServiceServer that writes to a Writer.

func NewRPCReceiver added in v0.7.1

func NewRPCReceiver(w Writer) *RPCReceiver

NewRPCReceiver returns a new RPCReceiver.

func (*RPCReceiver) WriteUpdates added in v0.5.0

func (recv *RPCReceiver) WriteUpdates(srv ProgressService_WriteUpdatesServer) error

WriteUpdates implements ProgressServiceServer.

type RPCWriter

type RPCWriter struct {
	Conn    *grpc.ClientConn
	Updates ProgressService_WriteUpdatesClient
	// contains filtered or unexported fields
}

RPCWriter is a Writer that writes to a ProgressService.

func NewRPCWriter added in v0.7.1

func NewRPCWriter(conn *grpc.ClientConn, updates ProgressService_WriteUpdatesClient) *RPCWriter

NewRPCWriter returns a new RPCWriter.

func (*RPCWriter) Close

func (w *RPCWriter) Close() error

Close closes the underlying RPC connection.

func (*RPCWriter) WriteStatus

func (w *RPCWriter) WriteStatus(status *StatusUpdate) error

WriteStatus implements Writer.

type Reader

type Reader interface {
	ReadStatus() (*StatusUpdate, bool)
}

type Recorder

type Recorder struct {
	Group *Group
	// contains filtered or unexported fields
}

Recorder is a Writer that also tracks a current group.

func FromContext added in v0.10.0

func FromContext(ctx context.Context) *Recorder

FromContext returns the Recorder attached to the given context, or a no-op Recorder if none is attached.

func NewRecorder

func NewRecorder(w Writer, opts ...GroupOpt) *Recorder

NewRecorder creates a new Recorder which writes to the given Writer.

It also initializes the "root" group and sends a progress update for the group.

func RecorderFromContext deprecated

func RecorderFromContext(ctx context.Context) *Recorder

RecorderFromContext returns the Recorder attached to the given context, or a no-op Recorder if none is attached.

Deprecated: use FromContext instead.

func WithGroup added in v0.2.0

func WithGroup(ctx context.Context, name string, opts ...GroupOpt) (context.Context, *Recorder)

WithGroup is shorthand for FromContext(ctx).WithGroup(name, opts...).

It returns a new context with the resulting Recorder attached.

func (*Recorder) Close

func (recorder *Recorder) Close() error

Close closes the underlying Writer.

func (*Recorder) Complete

func (recorder *Recorder) Complete()

Complete marks any current group and all sub-groups as complete, and sends a progress update for each.

func (*Recorder) Debug added in v0.8.0

func (recorder *Recorder) Debug(msg string, opts ...MessageOpt)

Debug sends a progress update with a debug-level message.

func (*Recorder) Error added in v0.8.0

func (recorder *Recorder) Error(msg string, opts ...MessageOpt)

Warn sends a progress update with an error-level message.

func (*Recorder) Join added in v0.2.0

func (recorder *Recorder) Join(vertexes ...digest.Digest)

Join sends a progress update that the given vertexes are members of the current group.

If the Recorder does not have a group, it does nothing.

func (*Recorder) Record

func (recorder *Recorder) Record(status *StatusUpdate) error

Record sends a deep-copy of the status update to the Writer.

func (*Recorder) Vertex

func (recorder *Recorder) Vertex(dig digest.Digest, name string, opts ...VertexOpt) *VertexRecorder

Vertex creates a new VertexRecorder for the given vertex.

While the digest can technically be an arbitrary string, it is given a digest.Digest type hint to suggest that it should be content-addressed.

The vertex will be associated to the group of the Recorder. The root Recorder keeps track of all group memberships seen for a given digest, and will emit a union of all groups.

func (*Recorder) Warn added in v0.8.0

func (recorder *Recorder) Warn(msg string, opts ...MessageOpt)

Warn sends a progress update with a warning-level message.

func (*Recorder) WithGroup

func (recorder *Recorder) WithGroup(name string, opts ...GroupOpt) *Recorder

WithGroup creates a new group and sends a progress update.

Calling WithGroup with the same name will always return the same Recorder instance so that you can record to a single hierarchy of groups. When the group already exists, opts are ignored.

type RunFunc added in v0.10.0

type RunFunc = func(context.Context, UIClient) error

type StatusInfo added in v0.6.0

type StatusInfo struct {
	Name  string
	Value string
	Order int
}

type StatusUpdate

type StatusUpdate struct {

	// Vertexes contains the set of vertex updates.
	Vertexes []*Vertex `protobuf:"bytes,1,rep,name=vertexes,proto3" json:"vertexes,omitempty"`
	// Tasks contains the set of tasks updates.
	Tasks []*VertexTask `protobuf:"bytes,2,rep,name=tasks,proto3" json:"tasks,omitempty"`
	// Logs contains the set of new log output.
	Logs []*VertexLog `protobuf:"bytes,3,rep,name=logs,proto3" json:"logs,omitempty"`
	// Groups contains a set of groups updates.
	Groups []*Group `protobuf:"bytes,4,rep,name=groups,proto3" json:"groups,omitempty"`
	// Memberships contains a set of membership updates.
	Memberships []*Membership `protobuf:"bytes,5,rep,name=memberships,proto3" json:"memberships,omitempty"`
	// Messages contains global messages to show to the user.
	Messages []*Message `protobuf:"bytes,6,rep,name=messages,proto3" json:"messages,omitempty"`
	// Sent is an optional timestamp that the status update was emitted.
	Sent *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=sent,proto3,oneof" json:"sent,omitempty"`
	// Received is an optional timestamp that the status update was received.
	Received *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=received,proto3,oneof" json:"received,omitempty"`
	// contains filtered or unexported fields
}

StatusUpdate contains a snapshot of state updates for the graph.

func (*StatusUpdate) Descriptor deprecated

func (*StatusUpdate) Descriptor() ([]byte, []int)

Deprecated: Use StatusUpdate.ProtoReflect.Descriptor instead.

func (*StatusUpdate) GetGroups

func (x *StatusUpdate) GetGroups() []*Group

func (*StatusUpdate) GetLogs

func (x *StatusUpdate) GetLogs() []*VertexLog

func (*StatusUpdate) GetMemberships added in v0.2.0

func (x *StatusUpdate) GetMemberships() []*Membership

func (*StatusUpdate) GetMessages added in v0.8.0

func (x *StatusUpdate) GetMessages() []*Message

func (*StatusUpdate) GetReceived added in v0.8.0

func (x *StatusUpdate) GetReceived() *timestamppb.Timestamp

func (*StatusUpdate) GetSent added in v0.8.0

func (x *StatusUpdate) GetSent() *timestamppb.Timestamp

func (*StatusUpdate) GetTasks

func (x *StatusUpdate) GetTasks() []*VertexTask

func (*StatusUpdate) GetVertexes

func (x *StatusUpdate) GetVertexes() []*Vertex

func (*StatusUpdate) ProtoMessage

func (*StatusUpdate) ProtoMessage()

func (*StatusUpdate) ProtoReflect

func (x *StatusUpdate) ProtoReflect() protoreflect.Message

func (*StatusUpdate) Reset

func (x *StatusUpdate) Reset()

func (*StatusUpdate) String

func (x *StatusUpdate) String() string

type Tape added in v0.1.1

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

Tape is a Writer that collects all progress output for displaying in a terminal UI.

func NewTape added in v0.1.1

func NewTape() *Tape

NewTape returns a new Tape.

func (*Tape) Activity added in v0.8.0

func (tape *Tape) Activity(vtx *Vertex) VertexActivity

func (*Tape) CachedCount added in v0.10.0

func (tape *Tape) CachedCount() int

CachedCount returns the number of cached vertexes. TODO: cache this

func (*Tape) Close added in v0.1.1

func (tape *Tape) Close() error

Close marks the Tape as done, which tells it to display all vertex output for the final render.

func (*Tape) Closed added in v0.10.0

func (tape *Tape) Closed() bool

Closed returns whether the Tape has been closed.

func (*Tape) CompletedCount added in v0.1.1

func (tape *Tape) CompletedCount() int

CompletedCount returns the number of completed vertexes. TODO: cache this

func (*Tape) Duration added in v0.10.0

func (tape *Tape) Duration() time.Duration

Duration returns the duration that the Tape has been accepting updates until Close has been called.

func (*Tape) EachVertex added in v0.4.1

func (tape *Tape) EachVertex(f func(*Vertex, *ui.Vterm) error) error

func (*Tape) ErroredCount added in v0.10.0

func (tape *Tape) ErroredCount() int

ErroredCount returns the number of errored vertexes. TODO: cache this

func (*Tape) Focus added in v0.7.0

func (tape *Tape) Focus(focused bool)

Focus sets whether to hide output of non-focused vertexes.

func (*Tape) MessageLevel added in v0.8.0

func (tape *Tape) MessageLevel(level MessageLevel)

MessageLevel sets the minimum level for messages to display.

func (*Tape) Render added in v0.1.1

func (tape *Tape) Render(w io.Writer, u *UI) error

func (*Tape) RevealErrored added in v0.10.0

func (tape *Tape) RevealErrored(reveal bool)

RevealErrored sets whether to show errored vertexes even when they would otherwise not be shown (i.e. internal, or focusing). You may want to set this when debugging, or for features that might break when bootstrapping before a higher level error can be shown.

func (*Tape) RunningCount added in v0.10.0

func (tape *Tape) RunningCount() int

UncachedCount returns the number of completed uncached vertexes. TODO: cache this

func (*Tape) RunningVertex added in v0.7.0

func (tape *Tape) RunningVertex() *Vertex

func (*Tape) SetWindowSize added in v0.1.1

func (tape *Tape) SetWindowSize(w, h int)

SetWindowSize sets the size of the terminal UI, which influences the dimensions for vertex logs, progress bars, etc.

func (*Tape) ShowAllOutput added in v0.2.0

func (tape *Tape) ShowAllOutput(show bool)

ShowAllOutput sets whether to show output even for successful vertexes.

func (*Tape) ShowInternal added in v0.1.1

func (tape *Tape) ShowInternal(show bool)

ShowInternal sets whether to show internal vertexes in the output.

func (*Tape) TotalCount added in v0.1.1

func (tape *Tape) TotalCount() int

TotalCount returns the total number of vertexes.

func (*Tape) UncachedCount added in v0.10.0

func (tape *Tape) UncachedCount() int

UncachedCount returns the number of completed uncached vertexes. TODO: cache this

func (*Tape) VerboseEdges added in v0.1.1

func (tape *Tape) VerboseEdges(verbose bool)

VerboseEdges sets whether to display edges between vertexes in the same group.

func (*Tape) Vertices added in v0.7.0

func (tape *Tape) Vertices() []*Vertex

func (*Tape) WriteStatus added in v0.1.1

func (tape *Tape) WriteStatus(status *StatusUpdate) error

WriteStatus implements Writer by collecting vertex and task updates and writing vertex logs to internal virtual terminals.

type TaskRecorder

type TaskRecorder struct {
	*VertexRecorder

	Task *VertexTask
}

func (*TaskRecorder) Complete

func (recorder *TaskRecorder) Complete()

func (*TaskRecorder) Current

func (recorder *TaskRecorder) Current(cur int64)

func (*TaskRecorder) Done

func (recorder *TaskRecorder) Done(err error)

func (*TaskRecorder) Progress

func (recorder *TaskRecorder) Progress(cur, total int64)

func (*TaskRecorder) Start

func (recorder *TaskRecorder) Start()

func (*TaskRecorder) Wrap

func (recorder *TaskRecorder) Wrap(f func() error) error

type TermSetupFunc added in v0.10.0

type TermSetupFunc func(*midterm.Terminal) io.Writer

TermSetupFunc is a function that gets called when the vertex's zoomed pane resizes. It returns an optional io.Writer for accepting user input.

type UI

type UI struct {
	Spinner ui.Spinner
	// contains filtered or unexported fields
}

func DefaultUI

func DefaultUI() *UI

func NewUI

func NewUI(spinner ui.Spinner) *UI

func (*UI) ParseFS

func (ui *UI) ParseFS(fs fs.FS, globs ...string) error

func (*UI) RenderStatus

func (u *UI) RenderStatus(w io.Writer, tape *Tape, infos []StatusInfo) error

func (*UI) RenderTask

func (ui *UI) RenderTask(w io.Writer, v *VertexTask) error

func (*UI) RenderTerm

func (ui *UI) RenderTerm(w io.Writer, term *ui.Vterm) error

func (*UI) RenderTrailer added in v0.6.0

func (ui *UI) RenderTrailer(w io.Writer, infos []StatusInfo) error

func (*UI) RenderVertex

func (ui *UI) RenderVertex(w io.Writer, v *Vertex) error

func (*UI) RenderVertexTree added in v0.10.0

func (ui *UI) RenderVertexTree(w io.Writer, v *Vertex) error

func (*UI) Run added in v0.10.0

func (u *UI) Run(ctx context.Context, tape *Tape, fn RunFunc) error

func (*UI) SetWindowSize

func (ui *UI) SetWindowSize(width, height int)

type UIClient added in v0.10.0

type UIClient interface {
	SetStatusInfo(StatusInfo)
}

UIClient is an interface for miscellaneous UI-only knobs.

type UnimplementedProgressServiceServer added in v0.5.0

type UnimplementedProgressServiceServer struct {
}

UnimplementedProgressServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedProgressServiceServer) WriteUpdates added in v0.5.0

type UnsafeProgressServiceServer added in v0.5.0

type UnsafeProgressServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeProgressServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ProgressServiceServer will result in compilation errors.

type Vertex

type Vertex struct {

	// ID is a unique identifier for the vertex, such as a digest.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Name is a user-visible name for the vertex.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Inputs contains IDs of vertices that this vertex depends on.
	Inputs []string `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"`
	// Outputs contains IDs of vertices that this vertex created.
	//
	// The intention is to allow a vertex to express that it created other
	// vertexes which may not maintain an input relationship to its creator, for
	// example an API request that created an object that may have otherwise been
	// created in some other way.
	Outputs []string `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"`
	// Started is the time that the vertex started evaluating.
	Started *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=started,proto3,oneof" json:"started,omitempty"`
	// Completed is the time that the vertex finished evaluating.
	Completed *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=completed,proto3,oneof" json:"completed,omitempty"`
	// Cached indicates whether the vertex resulted in a cache hit.
	Cached bool `protobuf:"varint,7,opt,name=cached,proto3" json:"cached,omitempty"`
	// Error is the error message, if any, that occurred while evaluating the
	// vertex.
	Error *string `protobuf:"bytes,8,opt,name=error,proto3,oneof" json:"error,omitempty"`
	// Canceled indicates whether the vertex was interrupted.
	Canceled bool `protobuf:"varint,9,opt,name=canceled,proto3" json:"canceled,omitempty"`
	// Internal indicates that the vertex should not visible to the user by
	// default, but may be revealed with a flag.
	Internal bool `protobuf:"varint,10,opt,name=internal,proto3" json:"internal,omitempty"`
	// Focused indicates that the vertex is more important than other vertices,
	// and should perhaps be displayed more prominently. For example, this might
	// be used to mark the command that actually "does the thing" - runs the
	// tests, does a build, whatever.
	Focused bool `protobuf:"varint,11,opt,name=focused,proto3" json:"focused,omitempty"`
	// Zoomed indicates that this vertex should take up as much
	// screen real estate as possible. For example, this might
	// be used for running an interactive shell, or running
	// anything where there is a single primary output.
	Zoomed bool `protobuf:"varint,12,opt,name=zoomed,proto3" json:"zoomed,omitempty"`
	// contains filtered or unexported fields
}

Vertex is a node in the graph of work to be done.

func (*Vertex) Descriptor deprecated

func (*Vertex) Descriptor() ([]byte, []int)

Deprecated: Use Vertex.ProtoReflect.Descriptor instead.

func (*Vertex) Duration

func (vertex *Vertex) Duration() time.Duration

func (*Vertex) GetCached

func (x *Vertex) GetCached() bool

func (*Vertex) GetCanceled

func (x *Vertex) GetCanceled() bool

func (*Vertex) GetCompleted

func (x *Vertex) GetCompleted() *timestamppb.Timestamp

func (*Vertex) GetError

func (x *Vertex) GetError() string

func (*Vertex) GetFocused added in v0.7.0

func (x *Vertex) GetFocused() bool

func (*Vertex) GetId

func (x *Vertex) GetId() string

func (*Vertex) GetInputs

func (x *Vertex) GetInputs() []string

func (*Vertex) GetInternal

func (x *Vertex) GetInternal() bool

func (*Vertex) GetName

func (x *Vertex) GetName() string

func (*Vertex) GetOutputs

func (x *Vertex) GetOutputs() []string

func (*Vertex) GetStarted

func (x *Vertex) GetStarted() *timestamppb.Timestamp

func (*Vertex) GetZoomed added in v0.10.0

func (x *Vertex) GetZoomed() bool

func (*Vertex) HasInput

func (v *Vertex) HasInput(o *Vertex) bool

func (*Vertex) ProtoMessage

func (*Vertex) ProtoMessage()

func (*Vertex) ProtoReflect

func (x *Vertex) ProtoReflect() protoreflect.Message

func (*Vertex) Reset

func (x *Vertex) Reset()

func (*Vertex) String

func (x *Vertex) String() string

type VertexActivity added in v0.8.0

type VertexActivity struct {
	LastLine        string
	TasksCompleted  int64
	TasksTotal      int64
	TaskBarsCurrent int64
	TaskBarsTotal   int64
}

type VertexInstance added in v0.1.2

type VertexInstance struct {
	VertexId string
	GroupId  string
}

VertexInstance identifies a vertex at a specific point in time.

type VertexLog

type VertexLog struct {

	// Vertex is the ID of the vertex that emitted the log message.
	Vertex string `protobuf:"bytes,1,opt,name=vertex,proto3" json:"vertex,omitempty"`
	// Stream is the stream that the log message was emitted to.
	Stream LogStream `protobuf:"varint,2,opt,name=stream,proto3,enum=progrock.LogStream" json:"stream,omitempty"`
	// Data is the chunk of log output.
	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	// Timestamp is the time that the log message was emitted.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

VertexLog is a log message from a vertex.

func (*VertexLog) Descriptor deprecated

func (*VertexLog) Descriptor() ([]byte, []int)

Deprecated: Use VertexLog.ProtoReflect.Descriptor instead.

func (*VertexLog) GetData

func (x *VertexLog) GetData() []byte

func (*VertexLog) GetStream

func (x *VertexLog) GetStream() LogStream

func (*VertexLog) GetTimestamp

func (x *VertexLog) GetTimestamp() *timestamppb.Timestamp

func (*VertexLog) GetVertex

func (x *VertexLog) GetVertex() string

func (*VertexLog) ProtoMessage

func (*VertexLog) ProtoMessage()

func (*VertexLog) ProtoReflect

func (x *VertexLog) ProtoReflect() protoreflect.Message

func (*VertexLog) Reset

func (x *VertexLog) Reset()

func (*VertexLog) String

func (x *VertexLog) String() string

type VertexOpt

type VertexOpt func(*Vertex)

VertexOpt is an option for creating a Vertex.

func Focused added in v0.7.0

func Focused() VertexOpt

Focused marks the vertex as focused, indicating it should be shown in the UI when in focus mode.

func Internal

func Internal() VertexOpt

Internal marks the vertex as internal, meaning it will not be included in progress output by default.

func WithInputs

func WithInputs(inputs ...digest.Digest) VertexOpt

WithInputs sets the inputs for the vertex.

func Zoomed added in v0.10.0

func Zoomed(setup TermSetupFunc) VertexOpt

Zoomed marks the vertex as zoomed, indicating it should take up as much screen space as possible.

type VertexRecorder

type VertexRecorder struct {
	Vertex   *Vertex
	Recorder *Recorder
}

VertexRecorder records updates pertaining to a vertex.

func (*VertexRecorder) Cached

func (recorder *VertexRecorder) Cached()

Cached marks the vertex as cached and sends an update.

func (*VertexRecorder) Complete

func (recorder *VertexRecorder) Complete()

Complete marks the vertex as completed and sends an update.

func (*VertexRecorder) Done

func (recorder *VertexRecorder) Done(err error)

func (*VertexRecorder) Error

func (recorder *VertexRecorder) Error(err error)

Error marks the vertex as errored and sends an update.

If the error is context.Canceled or has it as a string suffix, the vertex will be marked as canceled instead.

func (*VertexRecorder) Output

func (recorder *VertexRecorder) Output(out digest.Digest)

Output records an output digest for the vertex and sends an update.

func (*VertexRecorder) ProgressTask

func (recorder *VertexRecorder) ProgressTask(total int64, msg string, args ...interface{}) *TaskRecorder

ProgressTask starts a task for the vertex and sends an update.

The task update includes the total value, which can be incremented with the returned recorder.

func (*VertexRecorder) Stderr

func (recorder *VertexRecorder) Stderr() io.Writer

Stderr returns an io.Writer that sends log updates for the STDERR stream.

func (*VertexRecorder) Stdout

func (recorder *VertexRecorder) Stdout() io.Writer

Stdout returns an io.Writer that sends log updates for the STDOUT stream.

func (*VertexRecorder) Task

func (recorder *VertexRecorder) Task(msg string, args ...interface{}) *TaskRecorder

Task starts a task for the vertex and sends an update.

type VertexTask

type VertexTask struct {

	// Vertex is the ID of the vertex that is performing the task.
	Vertex string `protobuf:"bytes,1,opt,name=vertex,proto3" json:"vertex,omitempty"`
	// Name is the user-visible name of the task.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Total is the total number of units of work to be done, such as the number
	// of bytes to be downloaded.
	Total int64 `protobuf:"varint,3,opt,name=total,proto3" json:"total,omitempty"`
	// Current is the number of units of work that have been completed.
	Current int64 `protobuf:"varint,4,opt,name=current,proto3" json:"current,omitempty"`
	// Started is the time that the task started.
	Started *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=started,proto3,oneof" json:"started,omitempty"`
	// Completed is the time that the task finished.
	Completed *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=completed,proto3,oneof" json:"completed,omitempty"`
	// contains filtered or unexported fields
}

VertexTask is a task that a vertex is performing.

func (*VertexTask) Descriptor deprecated

func (*VertexTask) Descriptor() ([]byte, []int)

Deprecated: Use VertexTask.ProtoReflect.Descriptor instead.

func (*VertexTask) Duration

func (task *VertexTask) Duration() time.Duration

func (*VertexTask) GetCompleted

func (x *VertexTask) GetCompleted() *timestamppb.Timestamp

func (*VertexTask) GetCurrent

func (x *VertexTask) GetCurrent() int64

func (*VertexTask) GetName

func (x *VertexTask) GetName() string

func (*VertexTask) GetStarted

func (x *VertexTask) GetStarted() *timestamppb.Timestamp

func (*VertexTask) GetTotal

func (x *VertexTask) GetTotal() int64

func (*VertexTask) GetVertex

func (x *VertexTask) GetVertex() string

func (*VertexTask) ProtoMessage

func (*VertexTask) ProtoMessage()

func (*VertexTask) ProtoReflect

func (x *VertexTask) ProtoReflect() protoreflect.Message

func (*VertexTask) Reset

func (x *VertexTask) Reset()

func (*VertexTask) String

func (x *VertexTask) String() string

type WaitWriter

type WaitWriter struct {
	Writer
	// contains filtered or unexported fields
}

WaitWriter is a Writer that waits for the RPC server to stop before closing the underlying Writer.

func (WaitWriter) Close

func (ww WaitWriter) Close() error

Close waits for the RPC server to stop and closes the underlying Writer.

type Writer

type Writer interface {
	WriteStatus(*StatusUpdate) error
	Close() error
}

func CreateJournal added in v0.9.0

func CreateJournal(filePath string) (Writer, error)

func DialRPC

func DialRPC(ctx context.Context, target string) (Writer, error)

DialRPC dials a ProgressService at the given target.

func ServeRPC

func ServeRPC(l net.Listener, w Writer) (Writer, error)

ServeRPC serves a ProgressService over the given listener.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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