OLD | NEW |
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 dm | 5 package dm |
6 | 6 |
7 import ( | 7 import ( |
| 8 "math" |
| 9 |
8 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
9 ) | 11 ) |
10 | 12 |
11 const ( | 13 const ( |
12 // DefaultLimitMaxDataSize is the default MaxDataSize value (16MB). | 14 // DefaultLimitMaxDataSize is the default MaxDataSize value (16MB). |
13 DefaultLimitMaxDataSize = 16 * 1024 * 1024 | 15 DefaultLimitMaxDataSize = 16 * 1024 * 1024 |
14 | 16 |
15 // MaxLimitMaxDataSize is the maximum MaxDataSize value (30MB). | 17 // MaxLimitMaxDataSize is the maximum MaxDataSize value (30MB). |
16 MaxLimitMaxDataSize = 30 * 1024 * 1024 | 18 MaxLimitMaxDataSize = 30 * 1024 * 1024 |
17 ) | 19 ) |
18 | 20 |
| 21 // MakeWalkGraphIncludeAll makes a new WalkGraphReq_Include which has all the |
| 22 // boxes ticked. This should only be used when your application plans to dump |
| 23 // the resulting graph query data to some logging/debugging trace for humans. |
| 24 // |
| 25 // If you don't plan on dumping it for humans, please set the Include options |
| 26 // appropriately in order to avoid wasting bandwidth/cpu/datastore query time on |
| 27 // the server (and draining your DM quotas unnecessarially). |
| 28 func MakeWalkGraphIncludeAll() *WalkGraphReq_Include { |
| 29 return &WalkGraphReq_Include{ |
| 30 true, true, true, true, true, math.MaxUint32, true, true, true, |
| 31 } |
| 32 } |
| 33 |
19 // Normalize returns an error iff the WalkGraphReq is invalid. | 34 // Normalize returns an error iff the WalkGraphReq is invalid. |
20 func (w *WalkGraphReq) Normalize() error { | 35 func (w *WalkGraphReq) Normalize() error { |
| 36 if w.Auth != nil { |
| 37 if err := w.Auth.Normalize(); err != nil { |
| 38 return err |
| 39 } |
| 40 } |
| 41 |
21 if w.Query == nil { | 42 if w.Query == nil { |
22 return errors.New("must specify a Query") | 43 return errors.New("must specify a Query") |
23 } | 44 } |
24 if err := w.Query.Normalize(); err != nil { | 45 if err := w.Query.Normalize(); err != nil { |
25 return err | 46 return err |
26 } | 47 } |
27 | 48 |
28 if w.Mode == nil { | 49 if w.Mode == nil { |
29 w.Mode = &WalkGraphReq_Mode{} | 50 w.Mode = &WalkGraphReq_Mode{} |
30 } | 51 } |
(...skipping 14 matching lines...) Expand all Loading... |
45 if w.Limit.MaxDataSize > MaxLimitMaxDataSize { | 66 if w.Limit.MaxDataSize > MaxLimitMaxDataSize { |
46 w.Limit.MaxDataSize = MaxLimitMaxDataSize | 67 w.Limit.MaxDataSize = MaxLimitMaxDataSize |
47 } | 68 } |
48 | 69 |
49 if w.Include == nil { | 70 if w.Include == nil { |
50 w.Include = &WalkGraphReq_Include{} | 71 w.Include = &WalkGraphReq_Include{} |
51 } else { | 72 } else { |
52 if w.Include.AttemptResult { | 73 if w.Include.AttemptResult { |
53 w.Include.AttemptData = true | 74 w.Include.AttemptData = true |
54 } | 75 } |
| 76 if w.Include.NumExecutions == 0 { |
| 77 w.Include.ExecutionInfoUrl = false |
| 78 } |
55 } | 79 } |
56 return nil | 80 return nil |
57 } | 81 } |
OLD | NEW |