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

Side by Side Diff: dm/appengine/distributor/swarming/v1/isolate.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 | « dm/appengine/distributor/swarming/v1/distributor.go ('k') | dm/appengine/mutate/add_deps.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 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 swarming 5 package swarming
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "strings" 10 "strings"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 Digest: string(chnk.file.Digest), Size: *chnk.file.Size, 87 Digest: string(chnk.file.Digest), Size: *chnk.file.Size,
88 IsIsolated: chnk.isIso} 88 IsIsolated: chnk.isIso}
89 } 89 }
90 90
91 anonC, authC := httpClients(c) 91 anonC, authC := httpClients(c)
92 92
93 isoClient := isolatedclient.New( 93 isoClient := isolatedclient.New(
94 anonC, authC, isolateURL, isolatedclient.DefaultNamespace, nil, nil) 94 anonC, authC, isolateURL, isolatedclient.DefaultNamespace, nil, nil)
95 states, err := isoClient.Contains(c, dgsts) 95 states, err := isoClient.Contains(c, dgsts)
96 if err != nil { 96 if err != nil {
97 » » err = errors.Annotate(err). 97 » » err = errors.Annotate(err, "checking containment for %d digests" , len(dgsts)).Err()
98 » » » D("count", len(dgsts)).
99 » » » Reason("checking containment for %(count)d digests").
100 » » » Err()
101 return err 98 return err
102 } 99 }
103 return parallel.FanOutIn(func(ch chan<- func() error) { 100 return parallel.FanOutIn(func(ch chan<- func() error) {
104 for i, st := range states { 101 for i, st := range states {
105 if st != nil { 102 if st != nil {
106 i, st := i, st 103 i, st := i, st
107 ch <- func() error { 104 ch <- func() error {
108 return isoClient.Push(c, st, isolatedcli ent.NewBytesSource(chunks[i].data)) 105 return isoClient.Push(c, st, isolatedcli ent.NewBytesSource(chunks[i].data))
109 } 106 }
110 } 107 }
111 } 108 }
112 }) 109 })
113 } 110 }
114 111
115 func prepIsolate(c context.Context, isolateURL string, desc *dm.Quest_Desc, prev *dm.JsonResult, params *sv1.Parameters) (*swarm.SwarmingRpcsFilesRef, error) { 112 func prepIsolate(c context.Context, isolateURL string, desc *dm.Quest_Desc, prev *dm.JsonResult, params *sv1.Parameters) (*swarm.SwarmingRpcsFilesRef, error) {
116 prevData := []byte("{}") 113 prevData := []byte("{}")
117 if prev != nil { 114 if prev != nil {
118 prevData = []byte(prev.Object) 115 prevData = []byte(prev.Object)
119 } 116 }
120 prevFile := mkFile(prevData) 117 prevFile := mkFile(prevData)
121 descData, descFile := mkMsgFile(desc) 118 descData, descFile := mkMsgFile(desc)
122 isoData, isoFile := mkIsolated(c, params, prevFile, descFile) 119 isoData, isoFile := mkIsolated(c, params, prevFile, descFile)
123 120
124 err := pushIsolate(c, isolateURL, []isoChunk{ 121 err := pushIsolate(c, isolateURL, []isoChunk{
125 {data: prevData, file: prevFile}, 122 {data: prevData, file: prevFile},
126 {data: descData, file: descFile}, 123 {data: descData, file: descFile},
127 {data: isoData, file: isoFile, isIso: true}, 124 {data: isoData, file: isoFile, isIso: true},
128 }) 125 })
129 if err != nil { 126 if err != nil {
130 » » err = errors.Annotate(err).Reason("pushing new Isolated").Err() 127 » » err = errors.Annotate(err, "pushing new Isolated").Err()
131 return nil, err 128 return nil, err
132 } 129 }
133 130
134 return &swarm.SwarmingRpcsFilesRef{ 131 return &swarm.SwarmingRpcsFilesRef{
135 Isolated: string(isoFile.Digest), 132 Isolated: string(isoFile.Digest),
136 Isolatedserver: isolateURL, 133 Isolatedserver: isolateURL,
137 Namespace: isolatedclient.DefaultNamespace, 134 Namespace: isolatedclient.DefaultNamespace,
138 }, nil 135 }, nil
139 } 136 }
OLDNEW
« no previous file with comments | « dm/appengine/distributor/swarming/v1/distributor.go ('k') | dm/appengine/mutate/add_deps.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698