Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAddress(build *buildbucketpb.Build) string
- func BuildsClient(c context.Context, host string, as auth.RPCAuthorityKind, ...) (buildbucketpb.BuildsClient, error)
- func CancelBuild(c context.Context, id int64, reason string) (*buildbucketpb.Build, error)
- func DeleteOldBuilds(c context.Context) error
- func FilterVisibleBuilders(c context.Context, builders []*buildbucketpb.BuilderID, project string) ([]*buildbucketpb.BuilderID, error)
- func GetBuildSummary(c context.Context, id int64) (*model.BuildSummary, error)
- func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error)
- func GetHost(c context.Context) (string, error)
- func GetRelatedBuildsTable(c context.Context, buildbucketID int64) (*ui.RelatedBuildsTable, error)
- func ProdBuildsClientFactory(c context.Context, host string, as auth.RPCAuthorityKind, ...) (buildbucketpb.BuildsClient, error)
- func PubSubHandler(c context.Context, message pubsub.Message, ...) error
- func RetryBuild(c context.Context, buildbucketID int64, requestID string) (*buildbucketpb.Build, error)
- func SyncBuilds(c context.Context) error
- func WithBuildsClientFactory(c context.Context, factory buildsClientFactory) context.Context
- type BlamelistOption
Constants ¶
const BuildSummaryStorageDuration = time.Hour * 24 * 30 * 20 // ~20 months
BuildSummaryStorageDuration is the maximum lifetime of a BuildSummary.
Lifetime is the time elapsed since the Build creation time. Cron runs periodically to scan and remove all the Builds of which lifetime exceeded this duration.
BuildSummaries are kept alive longer than builds in buildbuckets. So we can compute blamelist for builds that are at the end of their lifetime.
TODO(weiweilin): expose BuildStorageDuration from buildbucket and compute BuildSummaryStorageDuration base on that (e.g. add two months). So we can ensure BuildSummaries are kept alive longer than builds.
const BuildSummarySyncThreshold = time.Hour * 24 * 2 // 2 days
BuildSummarySyncThreshold is the maximum duration before Milo attempts to sync non-terminal builds with buildbucket.
Cron runs periodically to scan and sync all the non-terminal Builds of that was updated more than `BuildSummarySyncThreshold` ago.
Variables ¶
var ( ErrNotFound = errors.Reason("Build not found").Tag(grpcutil.NotFoundTag).Err() ErrNotLoggedIn = errors.Reason("not logged in").Tag(grpcutil.UnauthenticatedTag).Err() )
var ( FullBuildMask = &field_mask.FieldMask{ Paths: []string{ "id", "builder", "number", "created_by", "canceled_by", "create_time", "start_time", "end_time", "update_time", "status", "input", "output", "steps", "infra", "tags", "summary_markdown", "canary", "exe", }, } TagsAndGitilesMask = &field_mask.FieldMask{ Paths: []string{ "id", "number", "builder", "input.gitiles_commit", "tags", }, } )
Functions ¶
func BuildAddress ¶
func BuildAddress(build *buildbucketpb.Build) string
BuildAddress constructs the build address of a buildbucketpb.Build. This is used as the key for the BuildSummary entity.
func BuildsClient ¶
func BuildsClient(c context.Context, host string, as auth.RPCAuthorityKind, opts ...auth.RPCOption) (buildbucketpb.BuildsClient, error)
func CancelBuild ¶
CancelBuild cancels the build with the given ID.
func DeleteOldBuilds ¶
DeleteOldBuilds is a cron job that deletes BuildSummaries that are older than BuildSummaryStorageDuration.
func FilterVisibleBuilders ¶
func FilterVisibleBuilders(c context.Context, builders []*buildbucketpb.BuilderID, project string) ([]*buildbucketpb.BuilderID, error)
FilterVisibleBuilders returns a list of builders that are visible to the current user. When project is not an empty string, only builders in the specified project will be returned.
func GetBuildSummary ¶
GetBuildSummary fetches a build summary where the Context URI matches the given address.
func GetBuilderID ¶
func GetBuilderID(c context.Context, id int64) (builder *buildbucketpb.BuilderID, number int32, err error)
GetBuilderID returns the builder, and maybe the build number, for a build id.
func GetRelatedBuildsTable ¶
GetRelatedBuildsTable fetches all the related builds of the given build from Buildbucket.
func ProdBuildsClientFactory ¶
func ProdBuildsClientFactory(c context.Context, host string, as auth.RPCAuthorityKind, opts ...auth.RPCOption) (buildbucketpb.BuildsClient, error)
func PubSubHandler ¶
func PubSubHandler(c context.Context, message pubsub.Message, buildPubSub *buildbucketpb.BuildsV2PubSub) error
func RetryBuild ¶
func RetryBuild(c context.Context, buildbucketID int64, requestID string) (*buildbucketpb.Build, error)
RetryBuild retries the build with the given ID and returns the new build.
func SyncBuilds ¶
SyncBuilds is a cron job that sync BuildSummaries that are not in terminal state and haven't been updated recently.
Types ¶
type BlamelistOption ¶
type BlamelistOption int
BlamelistOption specifies whether the blamelist should be fetched as part of the build page request.
var ( // NoBlamelist means blamelist shouldn't be fetched. NoBlamelist BlamelistOption = 0 // GetBlamelist means blamelist should be fetched with a short timeout. GetBlamelist BlamelistOption = 1 // ForceBlamelist means blamelist should be fetched with a long timeout. ForceBlamelist BlamelistOption = 2 )