shards

package
v0.0.0-...-e7509a3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package shards provides methods to access the ReclusteringShards Spanner table. The table is used by reclustering shards to report progress.

Index

Constants

View Source
const MaxProgress = 1000

MaxProgress is the maximum progress value for a shard, corresponding to 100% complete reclustering.

Variables

View Source
var StartingEpoch = time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)

StartingEpoch is the earliest valid run attempt time.

Functions

func Create

func Create(ctx context.Context, r ReclusteringShard) error

Create inserts a new reclustering shard without progress.

func DeleteAll

func DeleteAll(ctx context.Context)

DeleteAll deletes all reclustering shards.

func SetShardsForTesting

func SetShardsForTesting(ctx context.Context, t testing.TB, rs []ReclusteringShard) error

SetShardsForTesting replaces the set of stored shards to match the given set.

func UpdateProgress

func UpdateProgress(ctx context.Context, shardNumber int64, attemptTimestamp time.Time, progress int) error

UpdateProgress updates the progress on a particular shard. Clients should be mindful of the fact that if they are late to update the progress, the entry for a shard may no longer exist.

Types

type ReclusteringProgress

type ReclusteringProgress struct {
	// The LUCI Project.
	Project string
	// The attempt. This is the time the orchestrator run ends.
	AttemptTimestamp time.Time
	// The number of shards running for the project.
	ShardCount int64
	// The number of shards which have reported progress.
	ShardsReported int64
	// The total progress reported for the project. This is a value
	// between 0 and 1000*ShardCount.
	Progress int64
}

ReclusteringProgress is the result of reading the progress of a project's shards for one reclustering attempt.

func ReadAllProgresses

func ReadAllProgresses(ctx context.Context, attemptTimestamp time.Time) ([]ReclusteringProgress, error)

ReadAllProgresses reads reclustering progress for ALL projects with shards, for the given attempt timestamp.

func ReadProgress

func ReadProgress(ctx context.Context, project string, attemptTimestamp time.Time) (ReclusteringProgress, error)

ReadProgress reads all the progress of reclustering the given LUCI Project, for the given attempt timestamp.

type ReclusteringShard

type ReclusteringShard struct {
	// A unique number assigned to shard. Shards are numbered sequentially,
	// starting from one.
	ShardNumber int64
	// The attempt. This is the time the orchestrator run ends.
	AttemptTimestamp time.Time
	// The LUCI Project the shard is doing reclustering for.
	Project string
	// The progress. This is a value between 0 and 1000. If this is NULL,
	// it means progress has not yet been reported by the shard.
	Progress spanner.NullInt64
}

ReclusteringShard is used to for shards to report progress re-clustering test results.

func ReadAll

func ReadAll(ctx context.Context) ([]ReclusteringShard, error)

ReadAll reads all reclustering shards. For testing use only.

type ShardBuilder

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

ShardBuilder provides methods to build a reclustering shard for testing.

func NewShard

func NewShard(uniqifier int) *ShardBuilder

NewShard starts building a new Shard, for testing.

func (*ShardBuilder) Build

func (b *ShardBuilder) Build() ReclusteringShard

func (*ShardBuilder) WithAttemptTimestamp

func (b *ShardBuilder) WithAttemptTimestamp(attemptTimestamp time.Time) *ShardBuilder

WithAttemptTimestamp specifies the attempt timestamp to use on the shard.

func (*ShardBuilder) WithNoProgress

func (b *ShardBuilder) WithNoProgress() *ShardBuilder

WithNoProgress sets that the shard has not reported progress.

func (*ShardBuilder) WithProgress

func (b *ShardBuilder) WithProgress(progress int) *ShardBuilder

WithProgress sets the progress on the shard. This should be a value between 0 and 1000.

func (*ShardBuilder) WithProject

func (b *ShardBuilder) WithProject(project string) *ShardBuilder

WithProject specifies the project to use on the shard.

func (*ShardBuilder) WithShardNumber

func (b *ShardBuilder) WithShardNumber(shardNumber int64) *ShardBuilder

WithShardNumber specifies the shard number to use on the shard.

Jump to

Keyboard shortcuts

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