buildeventrecorder

package
v0.0.0-...-a408733 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindOrCreateAuthenticatedUser

func FindOrCreateAuthenticatedUser(
	ctx context.Context,
	db database.Handle,
	authMetadataExtractors *authmetadataextraction.AuthMetadataExtractors,
	authenticatedUsersGauge prometheus.Gauge,
) (*int64, error)

FindOrCreateAuthenticatedUser creates a user or returns its ID if it already exists.

func FindOrCreateInstanceName

func FindOrCreateInstanceName(
	ctx context.Context,
	db database.Handle,
	instanceName string,
) (int64, error)

FindOrCreateInstanceName creates an instance name or returns its ID if it already exists.

func FindOrCreateInvocation

func FindOrCreateInvocation(
	ctx context.Context,
	db database.Handle,
	invocationUUID uuid.UUID,
	instanceNameDbID int64,
	authenticatedUserDbID *int64,
	invocationsGaugeVec *prometheus.GaugeVec,
) (int64, error)

FindOrCreateInvocation creates an invocation or returns its ID if it already exists.

func SaveSingleFile

func SaveSingleFile(ctx context.Context, tx database.Handle, instanceNameDbID int64, parsedFile files.ParsedBepFile) (int64, error)

SaveSingleFile saves a single file to the database

Types

type Batcher

type Batcher[T any] struct {
	// contains filtered or unexported fields
}

Batcher is a utility that atomically accumulates items to be processed in a batch.

func NewBatcher

func NewBatcher[T any]() *Batcher[T]

NewBatcher returns a new batcher.

func (*Batcher[T]) Add

func (b *Batcher[T]) Add(item T)

Add adds an item to the batch and signals that data is available to any consumer.

func (*Batcher[T]) Ready

func (b *Batcher[T]) Ready() chan struct{}

Ready signals that there may be data available. Consumers must be able to handle there being no as it might have already been grabbed.

func (*Batcher[T]) Swap

func (b *Batcher[T]) Swap(buffer []T) []T

Swap the underlying batch buffer.

type BuildEventRecorder

type BuildEventRecorder interface {
	// StartLoggingConnectionMetadata starts a logging routine that will
	// log that there is a connection alive and well for the specific
	// invocation.
	StartLoggingConnectionMetadata(ctx context.Context)
	// SaveBatch saves a batch of build events to the storage layer.
	SaveBatch(ctx context.Context, batch []BuildEventWithInfo) error
}

BuildEventRecorder performs the actual recording of build events for an invocation to the storage layer.

func NewBuildEventRecorder

func NewBuildEventRecorder(
	ctx context.Context,
	db database.Client,
	publishAuthorizer auth.Authorizer,
	saveDataLevel *bb_portal.BuildEventStreamService_SaveDataLevel,
	tracerProvider trace.TracerProvider,
	instanceName string,
	invocationID string,
	dataExtractors *DataExtractors,
	buildKey string,
	batchRetryTimeout time.Duration,
) (BuildEventRecorder, error)

NewBuildEventRecorder creates a new BuildEventRecorder

func NewMetricsBuildEventRecorder

func NewMetricsBuildEventRecorder(buildEventRecorder BuildEventRecorder) BuildEventRecorder

NewMetricsBuildEventRecorder decorates a BuildEventRecorder with prometheus metrics.

func NewMinDurationBuildEventRecorder

func NewMinDurationBuildEventRecorder(buildEventRecorder BuildEventRecorder, minDuration time.Duration) BuildEventRecorder

NewMinDurationBuildEventRecorder decorates a BuildEventRecorder so that it processes a batch for atleast as long as configured. This prevents small batches from consuming an undue amount of resources.

type BuildEventWithInfo

type BuildEventWithInfo struct {
	Event *bes.BuildEvent
	// Sequence number is int64 by spec, however it is also starting at
	// 1 and incrementing by 1 for each event by spec. We therefore
	// assume we can fit the SequenceNumber in an uint32 and in case we
	// can not we will refuse to process the event.
	SequenceNumber uint32
}

BuildEventWithInfo couples a build event with additional metadata required for processing.

type DataExtractors

type DataExtractors struct {
	AuthMetadataExtractors      *authmetadataextraction.AuthMetadataExtractors
	InvocationMetadataExtractor *jmespath.Expression
}

DataExtractors are used to extract specific data from a invocation in different ways.

type Factory

type Factory func(ctx context.Context, instanceName, invocationID string) (BuildEventRecorder, error)

Factory is a type for a factory that creates a new BuildEventRecorder.

Jump to

Keyboard shortcuts

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