status

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: 12 Imported by: 0

Documentation

Overview

Package status manages status values.

Package status manages status values.

Index

Constants

This section is empty.

Variables

View Source
var NotExistsErr error = errors.New("status value was not found")

NotExistsErr is returned when the requested object was not found in the database.

Functions

func ClearStatusUsers

func ClearStatusUsers(ctx context.Context) error

ClearStatusUsers clears the column CreateUser in table Status.

The retention policy is 63 days, but we delete it at 30 days to allow time to fix issues with the deletion process, as well as allow time for data to be wiped from the underlying storage media.

func Create

func Create(status *Status, currentUser string) (*spanner.Mutation, error)

Create creates a status entry in the Spanner Database. Must be called with an active RW transaction in the context. CreateUser and CreateTime in the passed in status will be ignored in favour of the commit time and the currentUser argument.

func GenerateID

func GenerateID() (string, error)

GenerateID returns a random 128-bit status ID, encoded as 32 lowercase hexadecimal characters.

func Validate

func Validate(status *Status) error

Validate validates a status value. It ignores the CreateUser and CreateTime fields. Reported field names are as they appear in the RPC documentation rather than the Go struct.

Types

type ListOptions

type ListOptions struct {
	// The offset into the list of statuses in the database to start reading at.
	Offset int64
	// The maximum number of items to return from the database.
	// If left as 0, the value of 100 will be used.
	Limit int64
}

ListOptions allows specifying extra options to the List method.

type Status

type Status struct {
	// The name of the tree this status is part of.
	TreeName string
	// The unique identifier for the status. This is a randomly generated
	// 128-bit ID, encoded as 32 lowercase hexadecimal characters.
	StatusID string
	// The general state of the tree.
	GeneralStatus pb.GeneralState
	// The message explaining details about the status.
	Message string
	// The username of the user who added this.  Will be
	// set to 'user' after the username TTL (of 30 days).
	CreateUser string
	// The time the status update was made.
	// If filling this in from commit timestamp, make sure to call .UTC(), i.e.
	// status.CreateTime = timestamp.UTC()
	CreateTime time.Time
	// The name of the LUCI builder that caused the tree to close.
	// Format: projects/{project}/buckets/{bucket}/builders/{builder}.
	ClosingBuilderName string
}

Status mirrors the structure of status values in the database.

func List

func List(ctx context.Context, treeName string, options *ListOptions) ([]*Status, bool, error)

List retrieves a list of status values from the database. Status values are listed in reverse CreateTime order (i.e. most recently created first). The options argument may be nil to use default options.

func ListAfter

func ListAfter(ctx context.Context, afterTime time.Time) ([]*Status, error)

ListAfter retrieves a list of status values from the Spanner that were created after a particular timestamp.

Status values are listed in ascending order of CreateTime.

func Read

func Read(ctx context.Context, treeName, statusID string) (*Status, error)

Read retrieves a status update from the database given the exact time the status update was made.

func ReadLatest

func ReadLatest(ctx context.Context, treeName string) (*Status, error)

ReadLatest retrieves the most recent status update for a tree from the database.

type StatusBuilder

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

func NewStatusBuilder

func NewStatusBuilder() *StatusBuilder

func (*StatusBuilder) Build

func (b *StatusBuilder) Build() *Status

func (*StatusBuilder) CreateInDB

func (b *StatusBuilder) CreateInDB(ctx context.Context) *Status

func (*StatusBuilder) WithClosingBuilderName

func (b *StatusBuilder) WithClosingBuilderName(closingBuilderName string) *StatusBuilder

func (*StatusBuilder) WithCreateTime

func (b *StatusBuilder) WithCreateTime(createTime time.Time) *StatusBuilder

func (*StatusBuilder) WithCreateUser

func (b *StatusBuilder) WithCreateUser(user string) *StatusBuilder

func (*StatusBuilder) WithGeneralStatus

func (b *StatusBuilder) WithGeneralStatus(state pb.GeneralState) *StatusBuilder

func (*StatusBuilder) WithMessage

func (b *StatusBuilder) WithMessage(message string) *StatusBuilder

func (*StatusBuilder) WithStatusID

func (b *StatusBuilder) WithStatusID(id string) *StatusBuilder

func (*StatusBuilder) WithTreeName

func (b *StatusBuilder) WithTreeName(treeName string) *StatusBuilder

Jump to

Keyboard shortcuts

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