Documentation ¶
Overview ¶
Package status manages status values.
Package status manages status values.
Index ¶
- Variables
- func ClearStatusUsers(ctx context.Context) error
- func Create(status *Status, currentUser string) (*spanner.Mutation, error)
- func GenerateID() (string, error)
- func Validate(status *Status) error
- type ListOptions
- type Status
- func List(ctx context.Context, treeName string, options *ListOptions) ([]*Status, bool, error)
- func ListAfter(ctx context.Context, afterTime time.Time) ([]*Status, error)
- func Read(ctx context.Context, treeName, statusID string) (*Status, error)
- func ReadLatest(ctx context.Context, treeName string) (*Status, error)
- type StatusBuilder
- func (b *StatusBuilder) Build() *Status
- func (b *StatusBuilder) CreateInDB(ctx context.Context) *Status
- func (b *StatusBuilder) WithClosingBuilderName(closingBuilderName string) *StatusBuilder
- func (b *StatusBuilder) WithCreateTime(createTime time.Time) *StatusBuilder
- func (b *StatusBuilder) WithCreateUser(user string) *StatusBuilder
- func (b *StatusBuilder) WithGeneralStatus(state pb.GeneralState) *StatusBuilder
- func (b *StatusBuilder) WithMessage(message string) *StatusBuilder
- func (b *StatusBuilder) WithStatusID(id string) *StatusBuilder
- func (b *StatusBuilder) WithTreeName(treeName string) *StatusBuilder
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
GenerateID returns a random 128-bit status ID, encoded as 32 lowercase hexadecimal characters.
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 ¶
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 ¶
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.
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