Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: milo/build_source/buildbucket/builder.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: copyright Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbucket 5 package buildbucket
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "fmt" 9 "fmt"
10 "net/url" 10 "net/url"
(...skipping 25 matching lines...) Expand all
36 *buildbucket.ApiSearchResponseMessage, error) { 36 *buildbucket.ApiSearchResponseMessage, error) {
37 37
38 var res *buildbucket.ApiSearchResponseMessage 38 var res *buildbucket.ApiSearchResponseMessage
39 err := retry.Retry( 39 err := retry.Retry(
40 c, 40 c,
41 retry.TransientOnly(retry.Default), 41 retry.TransientOnly(retry.Default),
42 func() error { 42 func() error {
43 var err error 43 var err error
44 res, err = req.Do() 44 res, err = req.Do()
45 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Co de >= 500 { 45 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Co de >= 500 {
46 » » » » err = errors.WrapTransient(apiErr) 46 » » » » err = retry.Tag.Apply(apiErr)
47 } 47 }
48 return err 48 return err
49 }, 49 },
50 func(err error, wait time.Duration) { 50 func(err error, wait time.Duration) {
51 logging.WithError(err).Warningf(c, "buildbucket search r equest failed transiently, will retry in %s", wait) 51 logging.WithError(err).Warningf(c, "buildbucket search r equest failed transiently, will retry in %s", wait)
52 }) 52 })
53 return res, err 53 return res, err
54 } 54 }
55 55
56 // fetchBuilds fetches builds given a criteria. 56 // fetchBuilds fetches builds given a criteria.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC() 287 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC()
288 } 288 }
289 289
290 type newBuildsFirst []*resp.BuildSummary 290 type newBuildsFirst []*resp.BuildSummary
291 291
292 func (a newBuildsFirst) Len() int { return len(a) } 292 func (a newBuildsFirst) Len() int { return len(a) }
293 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 293 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
294 func (a newBuildsFirst) Less(i, j int) bool { 294 func (a newBuildsFirst) Less(i, j int) bool {
295 return a[i].PendingTime.Started.After(a[j].PendingTime.Started) 295 return a[i].PendingTime.Started.After(a[j].PendingTime.Started)
296 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698