alerts

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package alerts manages alert values in the database.

Index

Constants

View Source
const (
	// StatusIDExpression is a partial regular expression that validates status identifiers.
	// For now this is quite loose to handle Sheriff-o-matic keys which contain builder name
	// strings, so could be any characters at all.
	// Example SOM key: chromium$!chrome$!ci$!linux-chromeos-chrome$!browser_tests on Ubuntu-22.04$!8754809345790718177
	// TODO: Once we switch away from sheriff-o-matic we should tighten this up.
	AlertKeyExpression = `[^/]+`
)

Variables

This section is empty.

Functions

func Put

func Put(alert *Alert) (*spanner.Mutation, error)

Put sets the data for the alert in the Spanner Database. Note that this implies removing the entry from the database if there is no non-default information to keep a small table size. ModifyTime in the passed in alert will be ignored in favour of the commit time.

func Validate

func Validate(alert *Alert) error

Validate validates an alert value. It ignores the ModifyTime fields. Reported field names are as they appear in the RPC documentation rather than the Go struct.

Types

type Alert

type Alert struct {
	// The key of the alert.
	// For now, this matches the key of the alert in Sheriff-o-Matic.
	// This may be revised in the future.
	AlertKey string
	// The bug number in Buganizer/IssueTracker.
	// 0 if the alert is not linked to a bug.
	Bug int64
	// GerritCL is the CL number associated with this alert.
	// 0 means the alert is not associated with any GerritCL.
	GerritCL int64
	// The build number to consider this alert silenced until.
	// 0 if the alert is not silenced.
	SilenceUntil int64
	// The time the alert was last modified.
	// Used to control TTL of alert values.
	ModifyTime time.Time
}

Alert mirrors the structure of alert values in the database.

func ReadBatch

func ReadBatch(ctx context.Context, keys []string) ([]*Alert, error)

ReadBatch retrieves a batch of alerts from the database. If no record exists for an alert in the database an alert struct with all fields other than the key set to zero values will be returned. Returned alerts are in the same order as the keys requested. At most 100 keys can be requested in a batch.

func (*Alert) Etag

func (a *Alert) Etag() string

Jump to

Keyboard shortcuts

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