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

Side by Side Diff: milo/appengine/logdog/build.go

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: Created 3 years, 10 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 logdog 5 package logdog
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "net/http" 9 "net/http"
10 "time" 10 "time"
(...skipping 26 matching lines...) Expand all
37 // defaultLogDogHost is the default LogDog host, if one isn't specified via 37 // defaultLogDogHost is the default LogDog host, if one isn't specified via
38 // query string. 38 // query string.
39 defaultLogDogHost = "luci-logdog.appspot.com" 39 defaultLogDogHost = "luci-logdog.appspot.com"
40 ) 40 )
41 41
42 // AnnotationStream represents a LogDog annotation protobuf stream. 42 // AnnotationStream represents a LogDog annotation protobuf stream.
43 type AnnotationStream struct { 43 type AnnotationStream struct {
44 Project cfgtypes.ProjectName 44 Project cfgtypes.ProjectName
45 Path types.StreamPath 45 Path types.StreamPath
46 46
47 » // logDogClient is the HTTP client to use for LogDog communication. 47 » // Client is the HTTP client to use for LogDog communication.
48 Client *coordinator.Client 48 Client *coordinator.Client
49 49
50 // cs is the unmarshalled annotation stream Step and associated data. 50 // cs is the unmarshalled annotation stream Step and associated data.
51 cs internal.CachedStep 51 cs internal.CachedStep
52 } 52 }
53 53
54 // Normalize validates and normalizes the stream's parameters. 54 // Normalize validates and normalizes the stream's parameters.
55 func (as *AnnotationStream) Normalize() error { 55 func (as *AnnotationStream) Normalize() error {
56 if err := as.Project.Validate(); err != nil { 56 if err := as.Project.Validate(); err != nil {
57 return fmt.Errorf("Invalid project name: %s", as.Project) 57 return fmt.Errorf("Invalid project name: %s", as.Project)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // No substep had an ended time :( 205 // No substep had an ended time :(
206 latestEndedTime = google.TimeFromProto(step.Started) 206 latestEndedTime = google.TimeFromProto(step.Started)
207 } 207 }
208 208
209 // Build our CachedStep. 209 // Build our CachedStep.
210 as.cs = internal.CachedStep{ 210 as.cs = internal.CachedStep{
211 Step: &step, 211 Step: &step,
212 Finished: (state.State.TerminalIndex >= 0 && le.StreamIndex == u int64(state.State.TerminalIndex)), 212 Finished: (state.State.TerminalIndex >= 0 && le.StreamIndex == u int64(state.State.TerminalIndex)),
213 } 213 }
214 214
215 // Annotee is apparently not putting an ended time on some annotation pr otos.
216 // This hack will ensure that a finished build will always have an ended time.
217 if as.cs.Finished && as.cs.Step.Ended == nil {
218 as.cs.Step.Ended = google.NewTimestamp(latestEndedTime)
219 }
220
221 // Marshal and cache the step. If this is the final protobuf in the stre am, 215 // Marshal and cache the step. If this is the final protobuf in the stre am,
222 // cache it indefinitely; otherwise, cache it for intermediateCacheLifet ime. 216 // cache it indefinitely; otherwise, cache it for intermediateCacheLifet ime.
223 // 217 //
224 // If this fails, it is non-fatal. 218 // If this fails, it is non-fatal.
225 mcData, err := proto.Marshal(&as.cs) 219 mcData, err := proto.Marshal(&as.cs)
226 if err == nil { 220 if err == nil {
227 mcItem = mc.NewItem(c, mcKey) 221 mcItem = mc.NewItem(c, mcKey)
228 if !as.cs.Finished { 222 if !as.cs.Finished {
229 mcItem.SetExpiration(intermediateCacheLifetime) 223 mcItem.SetExpiration(intermediateCacheLifetime)
230 } 224 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if link.Label == "" { 303 if link.Label == "" {
310 link.Label = "unnamed" 304 link.Label = "unnamed"
311 } 305 }
312 return &link 306 return &link
313 307
314 default: 308 default:
315 // Don't know how to render. 309 // Don't know how to render.
316 return nil 310 return nil
317 } 311 }
318 } 312 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698