| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. |
| 5 |
// To regenerate this file run "make genpdata". |
| 6 |
|
| 7 |
package internal |
| 8 |
|
| 9 |
import ( |
| 10 |
"fmt" |
| 11 |
"sync" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/pdata/internal/json" |
| 14 |
"go.opentelemetry.io/collector/pdata/internal/proto" |
| 15 |
) |
| 16 |
|
| 17 |
// ExportResponse represents the response for gRPC/HTTP client/server. |
| 18 |
type ExportMetricsServiceResponse struct { |
| 19 |
PartialSuccess ExportMetricsPartialSuccess |
| 20 |
} |
| 21 |
|
| 22 |
var ( |
| 23 |
protoPoolExportMetricsServiceResponse = sync.Pool{ |
| 24 |
New: func() any { |
| 25 |
return &ExportMetricsServiceResponse{} |
| 26 |
}, |
| 27 |
} |
| 28 |
) |
| 29 |
|
| 30 |
func NewExportMetricsServiceResponse() *ExportMetricsServiceResponse { |
| 31 |
if !UseProtoPooling.IsEnabled() { |
| 32 |
return &ExportMetricsServiceResponse{} |
| 33 |
} |
| 34 |
return protoPoolExportMetricsServiceResponse.Get().(*ExportMetricsServiceResponse) |
| 35 |
} |
| 36 |
|
| 37 |
func DeleteExportMetricsServiceResponse(orig *ExportMetricsServiceResponse, nullable bool) { |
| 38 |
if orig == nil { |
| 39 |
return |
| 40 |
} |
| 41 |
|
| 42 |
if !UseProtoPooling.IsEnabled() { |
| 43 |
orig.Reset() |
| 44 |
return |
| 45 |
} |
| 46 |
|
| 47 |
DeleteExportMetricsPartialSuccess(&orig.PartialSuccess, false) |
| 48 |
|
| 49 |
orig.Reset() |
| 50 |
if nullable { |
| 51 |
protoPoolExportMetricsServiceResponse.Put(orig) |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
func CopyExportMetricsServiceResponse(dest, src *ExportMetricsServiceResponse) *ExportMetricsServiceResponse { |
| 56 |
// If copying to same object, just return. |
| 57 |
if src == dest { |
| 58 |
return dest |
| 59 |
} |
| 60 |
|
| 61 |
if src == nil { |
| 62 |
return nil |
| 63 |
} |
| 64 |
|
| 65 |
if dest == nil { |
| 66 |
dest = NewExportMetricsServiceResponse() |
| 67 |
} |
| 68 |
CopyExportMetricsPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) |
| 69 |
|
| 70 |
return dest |
| 71 |
} |
| 72 |
|
| 73 |
func CopyExportMetricsServiceResponseSlice(dest, src []ExportMetricsServiceResponse) []ExportMetricsServiceResponse { |
| 74 |
var newDest []ExportMetricsServiceResponse |
| 75 |
if cap(dest) < len(src) { |
| 76 |
newDest = make([]ExportMetricsServiceResponse, len(src)) |
| 77 |
} else { |
| 78 |
newDest = dest[:len(src)] |
| 79 |
// Cleanup the rest of the elements so GC can free the memory. |
| 80 |
// This can happen when len(src) < len(dest) < cap(dest). |
| 81 |
for i := len(src); i < len(dest); i++ { |
| 82 |
DeleteExportMetricsServiceResponse(&dest[i], false) |
| 83 |
} |
| 84 |
} |
| 85 |
for i := range src { |
| 86 |
CopyExportMetricsServiceResponse(&newDest[i], &src[i]) |
| 87 |
} |
| 88 |
return newDest |
| 89 |
} |
| 90 |
|
| 91 |
func CopyExportMetricsServiceResponsePtrSlice(dest, src []*ExportMetricsServiceResponse) []*ExportMetricsServiceResponse { |
| 92 |
var newDest []*ExportMetricsServiceResponse |
| 93 |
if cap(dest) < len(src) { |
| 94 |
newDest = make([]*ExportMetricsServiceResponse, len(src)) |
| 95 |
// Copy old pointers to re-use. |
| 96 |
copy(newDest, dest) |
| 97 |
// Add new pointers for missing elements from len(dest) to len(srt). |
| 98 |
for i := len(dest); i < len(src); i++ { |
| 99 |
newDest[i] = NewExportMetricsServiceResponse() |
| 100 |
} |
| 101 |
} else { |
| 102 |
newDest = dest[:len(src)] |
| 103 |
// Cleanup the rest of the elements so GC can free the memory. |
| 104 |
// This can happen when len(src) < len(dest) < cap(dest). |
| 105 |
for i := len(src); i < len(dest); i++ { |
| 106 |
DeleteExportMetricsServiceResponse(dest[i], true) |
| 107 |
dest[i] = nil |
| 108 |
} |
| 109 |
// Add new pointers for missing elements. |
| 110 |
// This can happen when len(dest) < len(src) < cap(dest). |
| 111 |
for i := len(dest); i < len(src); i++ { |
| 112 |
newDest[i] = NewExportMetricsServiceResponse() |
| 113 |
} |
| 114 |
} |
| 115 |
for i := range src { |
| 116 |
CopyExportMetricsServiceResponse(newDest[i], src[i]) |
| 117 |
} |
| 118 |
return newDest |
| 119 |
} |
| 120 |
|
| 121 |
func (orig *ExportMetricsServiceResponse) Reset() { |
| 122 |
*orig = ExportMetricsServiceResponse{} |
| 123 |
} |
| 124 |
|
| 125 |
// MarshalJSON marshals all properties from the current struct to the destination stream. |
| 126 |
func (orig *ExportMetricsServiceResponse) MarshalJSON(dest *json.Stream) { |
| 127 |
dest.WriteObjectStart() |
| 128 |
dest.WriteObjectField("partialSuccess") |
| 129 |
orig.PartialSuccess.MarshalJSON(dest) |
| 130 |
dest.WriteObjectEnd() |
| 131 |
} |
| 132 |
|
| 133 |
// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. |
| 134 |
func (orig *ExportMetricsServiceResponse) UnmarshalJSON(iter *json.Iterator) { |
| 135 |
for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { |
| 136 |
switch f { |
| 137 |
case "partialSuccess", "partial_success": |
| 138 |
|
| 139 |
orig.PartialSuccess.UnmarshalJSON(iter) |
| 140 |
default: |
| 141 |
iter.Skip() |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
func (orig *ExportMetricsServiceResponse) SizeProto() int { |
| 147 |
var n int |
| 148 |
var l int |
| 149 |
_ = l |
| 150 |
l = orig.PartialSuccess.SizeProto() |
| 151 |
n += 1 + proto.Sov(uint64(l)) + l |
| 152 |
return n |
| 153 |
} |
| 154 |
|
| 155 |
func (orig *ExportMetricsServiceResponse) MarshalProto(buf []byte) int { |
| 156 |
pos := len(buf) |
| 157 |
var l int |
| 158 |
_ = l |
| 159 |
l = orig.PartialSuccess.MarshalProto(buf[:pos]) |
| 160 |
pos -= l |
| 161 |
pos = proto.EncodeVarint(buf, pos, uint64(l)) |
| 162 |
pos-- |
| 163 |
buf[pos] = 0xa |
| 164 |
|
| 165 |
return len(buf) - pos |
| 166 |
} |
| 167 |
|
| 168 |
func (orig *ExportMetricsServiceResponse) UnmarshalProto(buf []byte) error { |
| 169 |
var err error |
| 170 |
var fieldNum int32 |
| 171 |
var wireType proto.WireType |
| 172 |
|
| 173 |
l := len(buf) |
| 174 |
pos := 0 |
| 175 |
for pos < l { |
| 176 |
// If in a group parsing, move to the next tag. |
| 177 |
fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) |
| 178 |
if err != nil { |
| 179 |
return err |
| 180 |
} |
| 181 |
switch fieldNum { |
| 182 |
|
| 183 |
case 1: |
| 184 |
if wireType != proto.WireTypeLen { |
| 185 |
return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) |
| 186 |
} |
| 187 |
var length int |
| 188 |
length, pos, err = proto.ConsumeLen(buf, pos) |
| 189 |
if err != nil { |
| 190 |
return err |
| 191 |
} |
| 192 |
startPos := pos - length |
| 193 |
|
| 194 |
err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos]) |
| 195 |
if err != nil { |
| 196 |
return err |
| 197 |
} |
| 198 |
default: |
| 199 |
pos, err = proto.ConsumeUnknown(buf, pos, wireType) |
| 200 |
if err != nil { |
| 201 |
return err |
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
return nil |
| 206 |
} |
| 207 |
|
| 208 |
func GenTestExportMetricsServiceResponse() *ExportMetricsServiceResponse { |
| 209 |
orig := NewExportMetricsServiceResponse() |
| 210 |
orig.PartialSuccess = *GenTestExportMetricsPartialSuccess() |
| 211 |
return orig |
| 212 |
} |
| 213 |
|
| 214 |
func GenTestExportMetricsServiceResponsePtrSlice() []*ExportMetricsServiceResponse { |
| 215 |
orig := make([]*ExportMetricsServiceResponse, 5) |
| 216 |
orig[0] = NewExportMetricsServiceResponse() |
| 217 |
orig[1] = GenTestExportMetricsServiceResponse() |
| 218 |
orig[2] = NewExportMetricsServiceResponse() |
| 219 |
orig[3] = GenTestExportMetricsServiceResponse() |
| 220 |
orig[4] = NewExportMetricsServiceResponse() |
| 221 |
return orig |
| 222 |
} |
| 223 |
|
| 224 |
func GenTestExportMetricsServiceResponseSlice() []ExportMetricsServiceResponse { |
| 225 |
orig := make([]ExportMetricsServiceResponse, 5) |
| 226 |
orig[1] = *GenTestExportMetricsServiceResponse() |
| 227 |
orig[3] = *GenTestExportMetricsServiceResponse() |
| 228 |
return orig |
| 229 |
} |