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 // This file contains types which are mirrors/duplicates of the upstream SDK | 5 // This file contains types which are mirrors/duplicates of the upstream SDK |
6 // types. This exists so that users can depend solely on this wrapper library | 6 // types. This exists so that users can depend solely on this wrapper library |
7 // without necessarially needing an SDK implementation present. | 7 // without necessarially needing an SDK implementation present. |
8 // | 8 // |
9 // This was done (instead of type-aliasing from the github version of the SDK) | 9 // This was done (instead of type-aliasing from the github version of the SDK) |
10 // because some of the types need to be tweaked (like Task.RetryOptions) to | 10 // because some of the types need to be tweaked (like Task.RetryOptions) to |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 // The number of times the task has been dispatched or leased. | 91 // The number of times the task has been dispatched or leased. |
92 RetryCount int32 | 92 RetryCount int32 |
93 | 93 |
94 // Tag for the task. Only used when Method is PULL. | 94 // Tag for the task. Only used when Method is PULL. |
95 Tag string | 95 Tag string |
96 | 96 |
97 // Retry options for this task. May be nil. | 97 // Retry options for this task. May be nil. |
98 RetryOptions *RetryOptions | 98 RetryOptions *RetryOptions |
99 } | 99 } |
100 | |
101 func (t *Task) Duplicate() *Task { | |
102 ret := &Task{} | |
dnj
2015/08/03 22:37:26
ret := *t
...
return &ret
iannucci
2015/08/04 01:21:21
Done.
| |
103 *ret = *t | |
104 | |
105 if t.Header != nil { | |
dnj
2015/08/03 22:37:25
len(t.Header) > 0
iannucci
2015/08/04 01:21:21
Done.
| |
106 ret.Header = make(http.Header, len(t.Header)) | |
107 for k, vs := range t.Header { | |
108 newVs := make([]string, len(vs)) | |
109 copy(newVs, vs) | |
110 ret.Header[k] = newVs | |
111 } | |
112 } | |
113 | |
114 if t.Payload != nil { | |
dnj
2015/08/03 22:37:26
len(t.Payload) > 0
iannucci
2015/08/04 01:21:21
Done.
| |
115 ret.Payload = make([]byte, len(t.Payload)) | |
116 copy(ret.Payload, t.Payload) | |
117 } | |
118 | |
119 if t.RetryOptions != nil { | |
120 ret.RetryOptions = &RetryOptions{} | |
121 *ret.RetryOptions = *t.RetryOptions | |
122 } | |
123 | |
124 return ret | |
125 } | |
OLD | NEW |