| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package logs | 5 package logs |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/url" | 8 "net/url" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 sreq := storage.GetRequest{ | 226 sreq := storage.GetRequest{ |
| 227 Path: p, | 227 Path: p, |
| 228 Index: types.MessageIndex(req.Index), | 228 Index: types.MessageIndex(req.Index), |
| 229 Limit: logCount, | 229 Limit: logCount, |
| 230 } | 230 } |
| 231 | 231 |
| 232 count := 0 | 232 count := 0 |
| 233 err := retry.Retry(c, retry.TransientOnly(retry.Default), func() error { | 233 err := retry.Retry(c, retry.TransientOnly(retry.Default), func() error { |
| 234 // Issue the Get request. This may return a transient error, in
which case | 234 // Issue the Get request. This may return a transient error, in
which case |
| 235 // we will retry. | 235 // we will retry. |
| 236 » » return st.Get(&sreq, func(idx types.MessageIndex, ld []byte) boo
l { | 236 » » return st.Get(sreq, func(idx types.MessageIndex, ld []byte) bool
{ |
| 237 if count > 0 && byteLimit-len(ld) < 0 { | 237 if count > 0 && byteLimit-len(ld) < 0 { |
| 238 // Not the first log, and we've exceeded our byt
e limit. | 238 // Not the first log, and we've exceeded our byt
e limit. |
| 239 return false | 239 return false |
| 240 } | 240 } |
| 241 byteLimit -= len(ld) | 241 byteLimit -= len(ld) |
| 242 | 242 |
| 243 if !(req.NonContiguous || idx == sreq.Index) { | 243 if !(req.NonContiguous || idx == sreq.Index) { |
| 244 return false | 244 return false |
| 245 } | 245 } |
| 246 logs = append(logs, ld) | 246 logs = append(logs, ld) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 log.ErrorKey: err, | 280 log.ErrorKey: err, |
| 281 "delay": delay, | 281 "delay": delay, |
| 282 }.Warningf(c, "Transient error while fetching tail log; retrying
.") | 282 }.Warningf(c, "Transient error while fetching tail log; retrying
.") |
| 283 }) | 283 }) |
| 284 if err != nil { | 284 if err != nil { |
| 285 log.WithError(err).Errorf(c, "Failed to fetch tail log.") | 285 log.WithError(err).Errorf(c, "Failed to fetch tail log.") |
| 286 return nil, err | 286 return nil, err |
| 287 } | 287 } |
| 288 return [][]byte{data}, err | 288 return [][]byte{data}, err |
| 289 } | 289 } |
| OLD | NEW |