status

package
v0.0.0-...-1c50ca4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package status manages status values.

Index

Constants

View Source
const (
	// TreeNameExpression is a partial regular expression that validates tree identifiers.
	TreeNameExpression = `[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?`
	// StatusIDExpression is a partial regular expression that validates status identifiers.
	StatusIDExpression = `[0-9a-f]{32}`
)

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
}

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 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.

Jump to

Keyboard shortcuts

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