| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 tumble | 5 package tumble |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "net/url" | 10 "net/url" |
| 11 "strconv" | 11 "strconv" |
| 12 "strings" | 12 "strings" |
| 13 "time" | 13 "time" |
| 14 | 14 |
| 15 "github.com/luci/luci-go/appengine/gaemiddleware" | 15 "github.com/luci/luci-go/appengine/gaemiddleware" |
| 16 "github.com/luci/luci-go/common/errors" | 16 "github.com/luci/luci-go/common/errors" |
| 17 "github.com/luci/luci-go/common/logging" | 17 "github.com/luci/luci-go/common/logging" |
| 18 "github.com/luci/luci-go/common/retry" |
| 18 "github.com/luci/luci-go/common/sync/parallel" | 19 "github.com/luci/luci-go/common/sync/parallel" |
| 19 "github.com/luci/luci-go/server/router" | 20 "github.com/luci/luci-go/server/router" |
| 20 | 21 |
| 21 ds "github.com/luci/gae/service/datastore" | 22 ds "github.com/luci/gae/service/datastore" |
| 22 "github.com/luci/gae/service/info" | 23 "github.com/luci/gae/service/info" |
| 23 | 24 |
| 24 "golang.org/x/net/context" | 25 "golang.org/x/net/context" |
| 25 ) | 26 ) |
| 26 | 27 |
| 27 const ( | 28 const ( |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return | 219 return |
| 219 } | 220 } |
| 220 | 221 |
| 221 cfg := getConfig(c) | 222 cfg := getConfig(c) |
| 222 | 223 |
| 223 logging.Infof(c, "Processing tasks in namespace %q", info.GetNamespace(c
)) | 224 logging.Infof(c, "Processing tasks in namespace %q", info.GetNamespace(c
)) |
| 224 err = processShard(c, cfg, time.Unix(tstamp, 0).UTC(), sid, loop) | 225 err = processShard(c, cfg, time.Unix(tstamp, 0).UTC(), sid, loop) |
| 225 if err != nil { | 226 if err != nil { |
| 226 logging.Errorf(c, "failure! %s", err) | 227 logging.Errorf(c, "failure! %s", err) |
| 227 | 228 |
| 228 » » if errors.IsTransient(err) { | 229 » » if retry.Tag.In(err) { |
| 229 rw.Header().Add(transientHTTPHeader, "true") | 230 rw.Header().Add(transientHTTPHeader, "true") |
| 230 } | 231 } |
| 231 rw.WriteHeader(http.StatusInternalServerError) | 232 rw.WriteHeader(http.StatusInternalServerError) |
| 232 fmt.Fprintf(rw, "error: %s", err) | 233 fmt.Fprintf(rw, "error: %s", err) |
| 233 } else { | 234 } else { |
| 234 rw.Write([]byte("ok")) | 235 rw.Write([]byte("ok")) |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 238 // getDatastoreNamespaces returns a list of all of the namespaces in the | 239 // getDatastoreNamespaces returns a list of all of the namespaces in the |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 query.Set("ns", ns) | 277 query.Set("ns", ns) |
| 277 } | 278 } |
| 278 if !loop { | 279 if !loop { |
| 279 query.Set("single", "1") | 280 query.Set("single", "1") |
| 280 } | 281 } |
| 281 if len(query) > 0 { | 282 if len(query) > 0 { |
| 282 v += "?" + query.Encode() | 283 v += "?" + query.Encode() |
| 283 } | 284 } |
| 284 return v | 285 return v |
| 285 } | 286 } |
| OLD | NEW |