events

package
v0.0.0-...-2c43d1c Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package events provides high-level functions for reading Bazel Event Protocol files or streams.

An event in this context means a Bazel Event Protocol event. These are defined by the Bazel project as protobuf. They are built as a Go library in github.com/buildbarn/bb-portal/third_party/bazel/gen/bes.

This package may provide convenience functions for working with those events, such as: - Iterating over events in a line-delimited JSON file (NDJSON file). - Converting events to/from a JSON array in order to save them in a DB as JSON.

This package should not contain any code to process or interpret events, and should not be aware of other types we define. This package should have very few dependencies. Ideally just the standard library & the libraries that are necessary to unmarshall the protobuf messages.

Index

Constants

View Source
const (
	UndeclaredTestOutputsName = "test.outputs__outputs.zip"
)

a constant for sizes

Variables

This section is empty.

Functions

func AsJSONArray

func AsJSONArray(buildEvents []*BuildEvent) (jsonb json.RawMessage, err error)

AsJSONArray Get it as a Json array.

Types

type BuildEvent

type BuildEvent struct {
	*bes.BuildEvent
	// contains filtered or unexported fields
}

BuildEvent A build event.

func FromJSONArray

func FromJSONArray(events json.RawMessage) (buildEvents []BuildEvent, err error)

FromJSONArray Get it from a JSON array.

func NewBuildEvent

func NewBuildEvent(event *bes.BuildEvent, eventBytes json.RawMessage) BuildEvent

NewBuildEvent creates a BuildEvent.

func (BuildEvent) Clone

func (e BuildEvent) Clone() BuildEvent

Clone returns a deep copy of the BuildEvent. In particular this avoids issues with the underlying rawEvent buffer changing.

func (BuildEvent) FindUndeclaredTestOutputsURI

func (e BuildEvent) FindUndeclaredTestOutputsURI() string

FindUndeclaredTestOutputsURI Find underclared outputs URI.

func (BuildEvent) GetActionCompletedLabel

func (e BuildEvent) GetActionCompletedLabel() string

GetActionCompletedLabel Get action complete label

func (BuildEvent) GetTargetCompletedLabel

func (e BuildEvent) GetTargetCompletedLabel() string

GetTargetCompletedLabel Get label for target completed.

func (BuildEvent) GetTargetConfiguredLabel

func (e BuildEvent) GetTargetConfiguredLabel() string

GetTargetConfiguredLabel GetTargetConfiguredLabel returns label of this event if it is `targetConfigured` event. Otherwise it returns an empty string.

func (BuildEvent) IsActionCompleted

func (e BuildEvent) IsActionCompleted() bool

IsActionCompleted Is the action completed.

func (BuildEvent) IsStructuredCommandLine

func (e BuildEvent) IsStructuredCommandLine() bool

IsStructuredCommandLine Is a structured command line.

func (BuildEvent) IsTargetCompleted

func (e BuildEvent) IsTargetCompleted() bool

IsTargetCompleted Is the Target Completed.

func (BuildEvent) IsTargetConfigured

func (e BuildEvent) IsTargetConfigured() bool

IsTargetConfigured IsTargetConfigured returns true if this event is `targetConfigured` event.

func (BuildEvent) IsTestResult

func (e BuildEvent) IsTestResult() bool

IsTestResult Is a test result.

func (BuildEvent) IsTestSummary

func (e BuildEvent) IsTestSummary() bool

IsTestSummary Is the Test Summary.

func (BuildEvent) IsWorkspaceStatus

func (e BuildEvent) IsWorkspaceStatus() bool

IsWorkspaceStatus Is a Workspace Status.

func (BuildEvent) RawMessage

func (e BuildEvent) RawMessage() json.RawMessage

RawMessage The Raw Message.

type BuildEventIterator

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

BuildEventIterator follows [googleapi's Iterator Guidelines](https://github.com/googleapis/google-cloud-go/wiki/Iterator-Guidelines). End of iteration is indicated with Done error from `google.golang.org/api/iterator` package being returned; it is returned for any subsequent calls, too. No pagination is provided.

func NewBuildEventIterator

func NewBuildEventIterator(ctx context.Context, reader io.Reader) *BuildEventIterator

NewBuildEventIterator Build Event Iterator constructor.

func (*BuildEventIterator) Next

func (it *BuildEventIterator) Next() (*BuildEvent, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done. If unknown field is encountered, it is ignored and no error is returned.

NOTE: Currently Next calls BuildEvent.Clone so it is safe for consumers to save the BuildEvent for later. In the future we may change this so that it is the consumers responsibility to clone the event if they are using it as more than a temporary variable inside a single iteration of the loop.

Jump to

Keyboard shortcuts

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