-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
passing build with ha_tracker now generated by csproto
- Loading branch information
1 parent
8f192ee
commit 30bad7a
Showing
7 changed files
with
326 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
// GENERATED CODE - DO NOT EDIT | ||
// This file was generated by protoc-gen-fastmarshal | ||
|
||
package distributor | ||
|
||
import ( | ||
"fmt" | ||
"sync/atomic" | ||
"github.com/CrowdStrike/csproto" | ||
) | ||
|
||
//------------------------------------------------------------------------------ | ||
// Custom Protobuf size/marshal/unmarshal code for ReplicaDesc | ||
|
||
// Size calculates and returns the size, in bytes, required to hold the contents of m using the Protobuf | ||
// binary encoding. | ||
func (m *ReplicaDesc) Size() int { | ||
// nil message is always 0 bytes | ||
if m == nil { | ||
return 0 | ||
} | ||
// return cached size, if present | ||
if csz := int(atomic.LoadInt32(&m.sizeCache)); csz > 0 { | ||
return csz | ||
} | ||
// calculate and cache | ||
var sz, l int | ||
_ = l // avoid unused variable | ||
|
||
// Replica (string,optional) | ||
if l = len(m.Replica); l > 0 { | ||
sz += csproto.SizeOfTagKey(1) + csproto.SizeOfVarint(uint64(l)) + l | ||
} | ||
// ReceivedAt (int64,optional) | ||
if m.ReceivedAt != 0 { | ||
sz += csproto.SizeOfTagKey(2) + csproto.SizeOfVarint(uint64(m.ReceivedAt)) | ||
} | ||
// DeletedAt (int64,optional) | ||
if m.DeletedAt != 0 { | ||
sz += csproto.SizeOfTagKey(3) + csproto.SizeOfVarint(uint64(m.DeletedAt)) | ||
} | ||
// ElectedAt (int64,optional) | ||
if m.ElectedAt != 0 { | ||
sz += csproto.SizeOfTagKey(4) + csproto.SizeOfVarint(uint64(m.ElectedAt)) | ||
} | ||
// ElectedChanges (int64,optional) | ||
if m.ElectedChanges != 0 { | ||
sz += csproto.SizeOfTagKey(5) + csproto.SizeOfVarint(uint64(m.ElectedChanges)) | ||
} | ||
// cache the size so it can be re-used in Marshal()/MarshalTo() | ||
atomic.StoreInt32(&m.sizeCache, int32(sz)) | ||
return sz | ||
} | ||
|
||
// Marshal converts the contents of m to the Protobuf binary encoding and returns the result or an error. | ||
func (m *ReplicaDesc) Marshal() ([]byte, error) { | ||
siz := m.Size() | ||
if siz == 0 { | ||
return []byte{}, nil | ||
} | ||
buf := make([]byte, siz) | ||
err := m.MarshalTo(buf) | ||
return buf, err | ||
} | ||
|
||
// MarshalTo converts the contents of m to the Protobuf binary encoding and writes the result to dest. | ||
func (m *ReplicaDesc) MarshalTo(dest []byte) error { | ||
// nil message == no-op | ||
if m == nil { | ||
return nil | ||
} | ||
var ( | ||
enc = csproto.NewEncoder(dest) | ||
buf []byte | ||
err error | ||
extVal interface{} | ||
) | ||
// ensure no unused variables | ||
_ = enc | ||
_ = buf | ||
_ = err | ||
_ = extVal | ||
|
||
// Replica (1,string,optional) | ||
if len(m.Replica) > 0 { | ||
enc.EncodeString(1, m.Replica) | ||
} | ||
// ReceivedAt (2,int64,optional) | ||
if m.ReceivedAt != 0 { | ||
enc.EncodeInt64(2, m.ReceivedAt) | ||
} | ||
// DeletedAt (3,int64,optional) | ||
if m.DeletedAt != 0 { | ||
enc.EncodeInt64(3, m.DeletedAt) | ||
} | ||
// ElectedAt (4,int64,optional) | ||
if m.ElectedAt != 0 { | ||
enc.EncodeInt64(4, m.ElectedAt) | ||
} | ||
// ElectedChanges (5,int64,optional) | ||
if m.ElectedChanges != 0 { | ||
enc.EncodeInt64(5, m.ElectedChanges) | ||
} | ||
return nil | ||
} | ||
|
||
// Unmarshal decodes a binary encoded Protobuf message from p and populates m with the result. | ||
func (m *ReplicaDesc) Unmarshal(p []byte) error { | ||
m.Reset() | ||
if len(p) == 0 { | ||
return nil | ||
} | ||
dec := csproto.NewDecoder(p) | ||
for dec.More() { | ||
tag, wt, err := dec.DecodeTag() | ||
if err != nil { | ||
return err | ||
} | ||
switch tag { | ||
case 1: // Replica (string,optional) | ||
if wt != csproto.WireTypeLengthDelimited { | ||
return fmt.Errorf("incorrect wire type %v for field 'replica' (tag=1), expected 2 (length-delimited)", wt) | ||
} | ||
if s, err := dec.DecodeString(); err != nil { | ||
return fmt.Errorf("unable to decode string value for field 'replica' (tag=1): %w", err) | ||
} else { | ||
m.Replica = s | ||
} | ||
|
||
case 2: // ReceivedAt (int64,optional) | ||
if wt != csproto.WireTypeVarint { | ||
return fmt.Errorf("incorrect wire type %v for tag field 'received_at' (tag=2), expected 0 (varint)", wt) | ||
} | ||
if v, err := dec.DecodeInt64(); err != nil { | ||
return fmt.Errorf("unable to decode int64 value for field 'received_at' (tag=2): %w", err) | ||
} else { | ||
m.ReceivedAt = v | ||
} | ||
case 3: // DeletedAt (int64,optional) | ||
if wt != csproto.WireTypeVarint { | ||
return fmt.Errorf("incorrect wire type %v for tag field 'deleted_at' (tag=3), expected 0 (varint)", wt) | ||
} | ||
if v, err := dec.DecodeInt64(); err != nil { | ||
return fmt.Errorf("unable to decode int64 value for field 'deleted_at' (tag=3): %w", err) | ||
} else { | ||
m.DeletedAt = v | ||
} | ||
case 4: // ElectedAt (int64,optional) | ||
if wt != csproto.WireTypeVarint { | ||
return fmt.Errorf("incorrect wire type %v for tag field 'elected_at' (tag=4), expected 0 (varint)", wt) | ||
} | ||
if v, err := dec.DecodeInt64(); err != nil { | ||
return fmt.Errorf("unable to decode int64 value for field 'elected_at' (tag=4): %w", err) | ||
} else { | ||
m.ElectedAt = v | ||
} | ||
case 5: // ElectedChanges (int64,optional) | ||
if wt != csproto.WireTypeVarint { | ||
return fmt.Errorf("incorrect wire type %v for tag field 'elected_changes' (tag=5), expected 0 (varint)", wt) | ||
} | ||
if v, err := dec.DecodeInt64(); err != nil { | ||
return fmt.Errorf("unable to decode int64 value for field 'elected_changes' (tag=5): %w", err) | ||
} else { | ||
m.ElectedChanges = v | ||
} | ||
|
||
default: | ||
if skipped, err := dec.Skip(tag, wt); err != nil { | ||
return fmt.Errorf("invalid operation skipping tag %v: %w", tag, err) | ||
} else { | ||
m.unknownFields = append(m.unknownFields, skipped...) | ||
} | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.