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 archive constructs a LogDog archive out of log stream components. | 5 // Package archive constructs a LogDog archive out of log stream components. |
6 // Records are read from the stream and emitted as an archive. | 6 // Records are read from the stream and emitted as an archive. |
7 package archive | 7 package archive |
8 | 8 |
9 import ( | 9 import ( |
10 "io" | 10 "io" |
11 | 11 |
12 "github.com/luci/luci-go/common/data/recordio" | 12 "github.com/luci/luci-go/common/data/recordio" |
13 "github.com/luci/luci-go/common/errors" | |
14 "github.com/luci/luci-go/common/logging" | 13 "github.com/luci/luci-go/common/logging" |
15 "github.com/luci/luci-go/common/sync/parallel" | 14 "github.com/luci/luci-go/common/sync/parallel" |
16 "github.com/luci/luci-go/logdog/api/logpb" | 15 "github.com/luci/luci-go/logdog/api/logpb" |
17 "github.com/luci/luci-go/logdog/common/renderer" | 16 "github.com/luci/luci-go/logdog/common/renderer" |
18 | 17 |
19 "github.com/golang/protobuf/proto" | 18 "github.com/golang/protobuf/proto" |
20 ) | 19 ) |
21 | 20 |
22 // Manifest is a set of archival parameters. | 21 // Manifest is a set of archival parameters. |
23 type Manifest struct { | 22 type Manifest struct { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return nil | 144 return nil |
146 } | 145 } |
147 | 146 |
148 return err | 147 return err |
149 } | 148 } |
150 | 149 |
151 } | 150 } |
152 } | 151 } |
153 }) | 152 }) |
154 | 153 |
155 // If any of the returned errors was transient, return a transient error
. | |
156 if errors.Any(err, errors.IsTransient) { | |
157 err = errors.WrapTransient(err) | |
158 } | |
159 return err | 154 return err |
160 } | 155 } |
161 | 156 |
162 func archiveLogs(w io.Writer, d *logpb.LogStreamDescriptor, logC <-chan *logpb.L
ogEntry, idx *indexBuilder) error { | 157 func archiveLogs(w io.Writer, d *logpb.LogStreamDescriptor, logC <-chan *logpb.L
ogEntry, idx *indexBuilder) error { |
163 offset := int64(0) | 158 offset := int64(0) |
164 out := func(pb proto.Message) error { | 159 out := func(pb proto.Message) error { |
165 d, err := proto.Marshal(pb) | 160 d, err := proto.Marshal(pb) |
166 if err != nil { | 161 if err != nil { |
167 return err | 162 return err |
168 } | 163 } |
(...skipping 12 matching lines...) Expand all Loading... |
181 } | 176 } |
182 | 177 |
183 // Add this LogEntry to our index, noting the current offset. | 178 // Add this LogEntry to our index, noting the current offset. |
184 if idx != nil { | 179 if idx != nil { |
185 idx.addLogEntry(le, offset) | 180 idx.addLogEntry(le, offset) |
186 } | 181 } |
187 err = out(le) | 182 err = out(le) |
188 } | 183 } |
189 return err | 184 return err |
190 } | 185 } |
OLD | NEW |