model

package
v0.0.0-...-15df1d5 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllTime = TimeRange{StartAt: TimeRangeMin, EndAt: TimeRangeMax}
View Source
var TimeRangeMax time.Time = time.Date(2200, 1, 1, 1, 0, 0, 0, time.UTC)

TimeRangeMax Chosen because it is effectively infinitely far in the future but UnixNano only works through 2262

View Source
var TimeRangeMin time.Time = time.Time{}

Functions

func CheckBuildMetadata

func CheckBuildMetadata(ctx context.Context, tracer otelTrace.Tracer, id string) (bool, error)

CheckBuildMetadata returns whether the metadata file exists for the given build.

func CheckTestMetadata

func CheckTestMetadata(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (bool, error)

CheckTestMetadata returns whether the metadata file exists for the given test.

func DownloadLogLines

func DownloadLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (chan *LogLineItem, error)

DownloadLogLines returns log lines for a given build ID and test ID. If the test ID is empty, this will return all logs lines in the build.

func InsertLogLines

func InsertLogLines(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string, lines []LogLineItem, maxSize int) error

InsertLogLines uploads log lines for a given build or test to the pail-backed offline storage. If the test ID is not empty, the logs are appended to the test for the given build, otherwise the logs are appended to the top-level build. A build ID is required in both cases.

func NewBuildID

func NewBuildID(ctx context.Context, tracer otelTrace.Tracer, builder string, buildNum int) (string, error)

NewBuildID generates a new build ID based on the hash of the given builder and build number.

func NewTestID

func NewTestID(startTime time.Time) string

NewTestID returns a new TestID with it's timestamp set to startTime. The ID is an ObjectID with its timestamp replaced with a nanosecond timestamp. It is represented as a hex string of 16 bytes. The first 8 bytes are the timestamp and replace the first 4 bytes of an ObjectID. The remaining 8 bytes are the rest of the ObjectID.

Types

type Build

type Build struct {
	ID            string `json:"id"`
	Builder       string `json:"builder"`
	BuildNum      int    `json:"buildnum"`
	TaskID        string `json:"task_id"`
	TaskExecution int    `json:"execution"`
}

Build contains metadata about a build.

func FindBuildByID

func FindBuildByID(ctx context.Context, tracer otelTrace.Tracer, id string) (*Build, error)

FindBuildByID returns the build metadata for the given ID from the pail-backed offline storage.

func (*Build) UploadMetadata

func (b *Build) UploadMetadata(ctx context.Context, tracer otelTrace.Tracer) error

UploadMetadata uploads metadata for a new build to the pail-backed offline storage.

type Iterator

type Iterator interface {
	// Next returns true if the iterator has not yet been exhausted or
	// closed, false otherwise.
	Next(context.Context) bool
	// Exhausted returns true if the iterator has not yet been exhausted,
	// regardless if it has been closed or not.
	Exhausted() bool
	// Err returns any errors that are captured by the iterator.
	Err() error
	// Close closes the iterator. This function should be called once the
	// iterator is no longer needed.
	Close() error
}

Iterator represents a cursor for generic iteration over a sequence of items.

type LogChunk

type LogChunk []LogLineItem

LogChunk is a grouping of lines.

type LogChunkInfo

type LogChunkInfo struct {
	BuildID  string
	TestID   string
	NumLines int
	Start    time.Time
	End      time.Time
}

LogChunkInfo describes a chunk of log lines stored in pail-backed offline storage.

type LogIterator

type LogIterator interface {
	Iterator
	// Item returns the current LogLine item held by the iterator.
	Item() LogLineItem
	// Reverse returns a reversed copy of the iterator.
	Reverse() LogIterator
	// IsReversed returns true if the iterator is in reverse order and
	// false otherwise.
	IsReversed() bool
	// Stream returns a chan of log lines from the iterator.
	Stream(context.Context) chan *LogLineItem
}

LogIterator is an interface that enables iterating over lines of buildlogger logs.

func NewBatchedLogIterator

func NewBatchedLogIterator(chunks []LogChunkInfo, batchSize int, timeRange TimeRange) LogIterator

NewBatchedLog returns a LogIterator that fetches batches (size set by the caller) of chunks from blob storage in parallel while iterating over lines of a buildlogger log.

func NewMergingIterator

func NewMergingIterator(iterators ...LogIterator) LogIterator

NewMergeIterator returns a LogIterator that merges N buildlogger logs, passed in as LogIterators, respecting the order of each line's timestamp.

func NewParallelizedLogIterator

func NewParallelizedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator

NewParallelizedLogIterator returns a LogIterator that fetches all chunks from blob storage in parallel while iterating over lines of a buildlogger log.

func NewSerializedLogIterator

func NewSerializedLogIterator(chunks []LogChunkInfo, timeRange TimeRange) LogIterator

NewSerializedLogIterator returns a LogIterator that serially fetches chunks from blob storage while iterating over lines of a buildlogger log.

type LogIteratorHeap

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

LogIteratorHeap is a heap of LogIterator items.

func (LogIteratorHeap) Len

func (h LogIteratorHeap) Len() int

Len returns the size of the heap.

func (LogIteratorHeap) Less

func (h LogIteratorHeap) Less(i, j int) bool

Less returns true if the object at index i is less than the object at index j in the heap, false otherwise, when min is true. When min is false, the opposite is returned.

func (*LogIteratorHeap) Pop

func (h *LogIteratorHeap) Pop() interface{}

Pop returns the next object (as an empty interface) from the heap. Note that if the heap is empty this will panic.

func (*LogIteratorHeap) Push

func (h *LogIteratorHeap) Push(x interface{})

Push appends a new object of type LogIterator to the heap. Note that if x is not a LogIterator nothing happens.

func (*LogIteratorHeap) SafePop

func (h *LogIteratorHeap) SafePop() LogIterator

SafePop is a wrapper function around heap.Pop that converts the returned interface into a LogIterator object before returning it.

func (*LogIteratorHeap) SafePush

func (h *LogIteratorHeap) SafePush(it LogIterator)

SafePush is a wrapper function around heap.Push that ensures, during compile time, that the correct type of object is put in the heap.

func (LogIteratorHeap) Swap

func (h LogIteratorHeap) Swap(i, j int)

Swap swaps the objects at indexes i and j.

type LogLineItem

type LogLineItem struct {
	Timestamp time.Time
	Data      string
	Global    bool
}

LogLineItem represents a single line in a log.

func UnmarshalLogJSON

func UnmarshalLogJSON(ctx context.Context, tracer otelTrace.Tracer, r io.Reader) ([]LogLineItem, error)

UnmarshalLogJSON unmarshals log lines from JSON into a slice of LogLineItem. Unmarshalling directly is more efficient than implementing the Unmarshaller interface.

func (*LogLineItem) LoggerName

func (item *LogLineItem) LoggerName() string

LoggerName returns the logger name for this line so it can be assigned a unique color when the log is displayed in the HTML view.

func (*LogLineItem) OneSecondNewer

func (item *LogLineItem) OneSecondNewer(previousItem interface{}) bool

OneSecondNewer returns if this line's timestamp is greater than one second newer than the previous line's timestamp.

type Test

type Test struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	BuildID       string `json:"build_id"`
	TaskID        string `json:"task_id"`
	TaskExecution int    `json:"execution"`
	Phase         string `json:"phase"`
	Command       string `json:"command"`
}

Test describes metadata of a test stored in pail-backed offline storage.

func FindTestByID

func FindTestByID(ctx context.Context, tracer otelTrace.Tracer, buildID string, testID string) (*Test, error)

FindTestByID returns the test metadata for the given build ID and test ID from the pail-backed offline storage.

func FindTestsForBuild

func FindTestsForBuild(ctx context.Context, tracer otelTrace.Tracer, buildID string) ([]Test, error)

FindTestsForBuild returns all of the test metadata for the given build ID from the pail-backed offline storage.

func (*Test) UploadTestMetadata

func (t *Test) UploadTestMetadata(ctx context.Context, tracer otelTrace.Tracer) error

UploadTestMetadata uploads metadata for a new test to the pail-backed offline storage.

type TimeRange

type TimeRange struct {
	StartAt time.Time `json:"start" yaml:"start"`
	EndAt   time.Time `json:"end" yaml:"end"`
}

func NewTimeRange

func NewTimeRange(start time.Time, end time.Time) TimeRange

NewTimeRange Creates a new time range. Use TimeRangeMin and TimeRangeMax for "open ended" time ranges

func (TimeRange) Duration

func (t TimeRange) Duration() time.Duration

func (TimeRange) Intersects

func (t TimeRange) Intersects(other TimeRange) bool

Intersects Check returns true if this TimeRange overlaps the other TimeRange

func (TimeRange) IsValid

func (t TimeRange) IsValid() bool

func (TimeRange) IsZero

func (t TimeRange) IsZero() bool

Jump to

Keyboard shortcuts

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