Documentation ¶
Overview ¶
Package checkpoints contains methods for maintaining and using process checkpoints to ensure processes run once only.
Index ¶
- func Exists(ctx context.Context, key Key) (bool, error)
- func Insert(ctx context.Context, key Key, ttl time.Duration) *spanner.Mutation
- func ReadAllUniquifiers(ctx context.Context, project, resourceID, processID string) (map[string]bool, error)
- func SetForTesting(ctx context.Context, t testing.TB, cs ...Checkpoint) error
- func SortKeys(cs []Key)
- type Checkpoint
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadAllUniquifiers ¶
func ReadAllUniquifiers(ctx context.Context, project, resourceID, processID string) (map[string]bool, error)
ReadAllUniquifiers returns all uniquifiers for a particular set of project, resourceID, processID. Return the map of uniquifiers to the value true.
func SetForTesting ¶
SetForTesting replaces the set of stored checkpoints to match the given set.
Types ¶
type Checkpoint ¶
type Checkpoint struct { Key // The time the checkpoint was created. CreationTime time.Time // The time the checkpoint will be eligible for deletion. ExpiryTime time.Time }
Checkpoint records that a point in a process was reached.
func ReadAllForTesting ¶
func ReadAllForTesting(ctx context.Context) ([]Checkpoint, error)
ReadAllForTesting reads all checkpoints for testing, e.g. to assert all expected checkpoints were made. Do not use in production, will not scale. Must be called in a spanner transactional context.
type Key ¶
type Key struct { // Project is the name of the LUCI Project. Project string // Identifier of the resource to which the checkpoint relates. // For example, the ResultDB invocation being ingested. // Free-form field, but must be non-empty. ResourceID string // ProcessID is the identifier of the process requiring checkpointing. // Valid pattern: ^[a-z0-9\-/]{1,64}$. ProcessID string // Unique identifier of the checkpoint within the process and resource. // Free-form field. // If the process has only one checkpoint, this may be empty (""). Uniquifier string }
Key is the primary key of a checkpoint.
Click to show internal directories.
Click to hide internal directories.