| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 collector | 5 package collector |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "time" | 9 "time" |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 return errors.New("failed to marshal log entries
") | 224 return errors.New("failed to marshal log entries
") |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Fetch our cached/remote state. This will replace our state object wit
h the | 229 // Fetch our cached/remote state. This will replace our state object wit
h the |
| 230 // fetched state, so any future calls will need to re-set the Secret val
ue. | 230 // fetched state, so any future calls will need to re-set the Secret val
ue. |
| 231 // TODO: Use timeout? | 231 // TODO: Use timeout? |
| 232 state, err := c.Coordinator.RegisterStream(ctx, &coordinator.LogStreamSt
ate{ | 232 state, err := c.Coordinator.RegisterStream(ctx, &coordinator.LogStreamSt
ate{ |
| 233 Path: h.path, | 233 Path: h.path, |
| 234 » » Secret: types.StreamSecret(h.be.Secret), | 234 » » Secret: types.PrefixSecret(h.be.Secret), |
| 235 ProtoVersion: h.md.ProtoVersion, | 235 ProtoVersion: h.md.ProtoVersion, |
| 236 }, h.be.Desc) | 236 }, h.be.Desc) |
| 237 if err != nil { | 237 if err != nil { |
| 238 log.WithError(err).Errorf(ctx, "Failed to get/register current s
tream state.") | 238 log.WithError(err).Errorf(ctx, "Failed to get/register current s
tream state.") |
| 239 return err | 239 return err |
| 240 } | 240 } |
| 241 | 241 |
| 242 // Does the log stream's secret match the expected secret? | 242 // Does the log stream's secret match the expected secret? |
| 243 if !bytes.Equal(h.be.Secret, []byte(state.Secret)) { | 243 if !bytes.Equal(h.be.Secret, []byte(state.Secret)) { |
| 244 log.Errorf(log.SetFields(ctx, log.Fields{ | 244 log.Errorf(log.SetFields(ctx, log.Fields{ |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 for _, e := range merr { | 337 for _, e := range merr { |
| 338 if hasTransientError(e) { | 338 if hasTransientError(e) { |
| 339 return true | 339 return true |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 return false | 342 return false |
| 343 } | 343 } |
| 344 | 344 |
| 345 return errors.IsTransient(err) | 345 return errors.IsTransient(err) |
| 346 } | 346 } |
| OLD | NEW |