util

package
v0.0.0-...-cf55a68 Latest Latest
Warning

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

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

Documentation

Overview

Package util contains the common utility functions shared by RunManager.

Index

Constants

View Source
const StaleCLAgeThreshold = 10 * time.Second

StaleCLAgeThreshold is the window that CL entity in datastore should be considered latest if refreshed within the threshold.

Large values increase the chance of returning false result on stale Change info while low values increase load on Gerrit.

Variables

This section is empty.

Functions

func IsActionTakenOnGerritCL

func IsActionTakenOnGerritCL(ctx context.Context, gf gerrit.Factory, rcl *run.RunCL, gerritQueryOpts []gerritpb.QueryOption, evalFn ActionTakeEvalFn) (time.Time, error)

IsActionTakenOnGerritCL checks whether an action specified by `evalFn` has been take on a Gerrit CL.

Checks against CV's own cache (CL entity in Datastore) first. If the action is not taken and cache is too old (before `now-StaleCLAgeThreshold“), then fetch the latest change info from Gerrit and check.

func MutateGerritCL

func MutateGerritCL(ctx context.Context, gf gerrit.Factory, rcl *run.RunCL, req *gerritpb.SetReviewRequest, leaseDuration time.Duration, motivation string) error

MutateGerritCL calls SetReview on the given Gerrit CL.

Uses mirror iterator and leases the CL before making the Gerrit call.

Types

type ActionTakeEvalFn

type ActionTakeEvalFn func(rcl *run.RunCL, ci *gerritpb.ChangeInfo) time.Time

ActionTakeEvalFn is the function signature to evaluate whether certain action has already been taken on the given Gerrit Change.

Returns the time when action is taken. Otherwise, returns zero time.

Jump to

Keyboard shortcuts

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