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

Side by Side Diff: logdog/appengine/coordinator/endpoints/logs/get.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits 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
« no previous file with comments | « grpc/prpc/client.go ('k') | logdog/appengine/coordinator/service.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logs 5 package logs
6 6
7 import ( 7 import (
8 "time" 8 "time"
9 9
10 "github.com/luci/luci-go/common/errors" 10 "github.com/luci/luci-go/common/errors"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 if !tail && req.LogCount < 0 && !signingRequest.HasWork() { 134 if !tail && req.LogCount < 0 && !signingRequest.HasWork() {
135 // No log operations are acutally needed, so don't bother instan ting our 135 // No log operations are acutally needed, so don't bother instan ting our
136 // Storage instance only to do nothing. 136 // Storage instance only to do nothing.
137 return nil 137 return nil
138 } 138 }
139 139
140 svc := coordinator.GetServices(c) 140 svc := coordinator.GetServices(c)
141 st, err := svc.StorageForStream(c, lst) 141 st, err := svc.StorageForStream(c, lst)
142 if err != nil { 142 if err != nil {
143 » » return errors.Annotate(err).InternalReason("failed to create sto rage instance").Err() 143 » » return errors.Annotate(err, "").InternalReason("failed to create storage instance").Err()
144 } 144 }
145 defer st.Close() 145 defer st.Close()
146 146
147 project, path := coordinator.Project(c), ls.Path() 147 project, path := coordinator.Project(c), ls.Path()
148 148
149 if tail { 149 if tail {
150 resp.Logs, err = getTail(c, st, project, path) 150 resp.Logs, err = getTail(c, st, project, path)
151 } else if req.LogCount >= 0 { 151 } else if req.LogCount >= 0 {
152 byteLimit := int(req.ByteCount) 152 byteLimit := int(req.ByteCount)
153 if byteLimit <= 0 || byteLimit > getBytesLimit { 153 if byteLimit <= 0 || byteLimit > getBytesLimit {
154 byteLimit = getBytesLimit 154 byteLimit = getBytesLimit
155 } 155 }
156 156
157 resp.Logs, err = getHead(c, req, st, project, path, byteLimit) 157 resp.Logs, err = getHead(c, req, st, project, path, byteLimit)
158 } 158 }
159 if err != nil { 159 if err != nil {
160 log.WithError(err).Errorf(c, "Failed to fetch log records.") 160 log.WithError(err).Errorf(c, "Failed to fetch log records.")
161 return err 161 return err
162 } 162 }
163 163
164 // If we're requesting a signedl URL, try and get that too. 164 // If we're requesting a signedl URL, try and get that too.
165 if signingRequest.HasWork() { 165 if signingRequest.HasWork() {
166 signedURLs, err := st.GetSignedURLs(c, &signingRequest) 166 signedURLs, err := st.GetSignedURLs(c, &signingRequest)
167 switch { 167 switch {
168 case err != nil: 168 case err != nil:
169 » » » return errors.Annotate(err).InternalReason("failed to ge nerate signed URL").Err() 169 » » » return errors.Annotate(err, "").InternalReason("failed t o generate signed URL").Err()
170 170
171 case signedURLs == nil: 171 case signedURLs == nil:
172 log.Debugf(c, "Signed URL was requested, but is not supp orted by storage.") 172 log.Debugf(c, "Signed URL was requested, but is not supp orted by storage.")
173 173
174 default: 174 default:
175 resp.SignedUrls = &logdog.GetResponse_SignedUrls{ 175 resp.SignedUrls = &logdog.GetResponse_SignedUrls{
176 Expiration: google.NewTimestamp(signedURLs.Expir ation), 176 Expiration: google.NewTimestamp(signedURLs.Expir ation),
177 Stream: signedURLs.Stream, 177 Stream: signedURLs.Stream,
178 Index: signedURLs.Index, 178 Index: signedURLs.Index,
179 } 179 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return []*logpb.LogEntry{le}, nil 294 return []*logpb.LogEntry{le}, nil
295 295
296 case storage.ErrDoesNotExist: 296 case storage.ErrDoesNotExist:
297 return nil, nil 297 return nil, nil
298 298
299 default: 299 default:
300 log.WithError(err).Errorf(c, "Failed to fetch tail log.") 300 log.WithError(err).Errorf(c, "Failed to fetch tail log.")
301 return nil, err 301 return nil, err
302 } 302 }
303 } 303 }
OLDNEW
« no previous file with comments | « grpc/prpc/client.go ('k') | logdog/appengine/coordinator/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698