| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 coordinator | 5 package coordinator |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "crypto/sha256" | 8 "crypto/sha256" |
| 9 "encoding/hex" | 9 "encoding/hex" |
| 10 "errors" | 10 "errors" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return fmt.Errorf("hash IDs don't match (%q != %q)", hid
, s.HashID) | 349 return fmt.Errorf("hash IDs don't match (%q != %q)", hid
, s.HashID) |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 if err := types.StreamName(s.Prefix).Validate(); err != nil { | 353 if err := types.StreamName(s.Prefix).Validate(); err != nil { |
| 354 return fmt.Errorf("invalid prefix: %s", err) | 354 return fmt.Errorf("invalid prefix: %s", err) |
| 355 } | 355 } |
| 356 if err := types.StreamName(s.Name).Validate(); err != nil { | 356 if err := types.StreamName(s.Name).Validate(); err != nil { |
| 357 return fmt.Errorf("invalid name: %s", err) | 357 return fmt.Errorf("invalid name: %s", err) |
| 358 } | 358 } |
| 359 » if len(s.Secret) != types.StreamSecretLength { | 359 » if err := types.PrefixSecret(s.Secret).Validate(); err != nil { |
| 360 » » return fmt.Errorf("invalid secret length (%d != %d)", len(s.Secr
et), types.StreamSecretLength) | 360 » » return fmt.Errorf("invalid prefix secret: %s", err) |
| 361 } | 361 } |
| 362 if s.ContentType == "" { | 362 if s.ContentType == "" { |
| 363 return errors.New("empty content type") | 363 return errors.New("empty content type") |
| 364 } | 364 } |
| 365 if s.Created.IsZero() { | 365 if s.Created.IsZero() { |
| 366 return errors.New("created time is not set") | 366 return errors.New("created time is not set") |
| 367 } | 367 } |
| 368 | 368 |
| 369 if s.Terminated() && s.TerminatedTime.IsZero() { | 369 if s.Terminated() && s.TerminatedTime.IsZero() { |
| 370 return errors.New("log stream is terminated, but missing termina
ted time") | 370 return errors.New("log stream is terminated, but missing termina
ted time") |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // were created before the supplied time. | 647 // were created before the supplied time. |
| 648 func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query { | 648 func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query { |
| 649 return q.Lt("Created", t.UTC()).Order("-Created") | 649 return q.Lt("Created", t.UTC()).Order("-Created") |
| 650 } | 650 } |
| 651 | 651 |
| 652 // AddNewerFilter adds a filter to queries that restricts them to results that | 652 // AddNewerFilter adds a filter to queries that restricts them to results that |
| 653 // were created after the supplied time. | 653 // were created after the supplied time. |
| 654 func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query { | 654 func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query { |
| 655 return q.Gt("Created", t.UTC()).Order("-Created") | 655 return q.Gt("Created", t.UTC()).Order("-Created") |
| 656 } | 656 } |
| OLD | NEW |