MCPcopy
hub / github.com/travisjeffery/jocko / Decode

Method Decode

protocol/fetch_request.go:44–99  ·  view source on GitHub ↗
(d PacketDecoder)

Source from the content-addressed store, hash-verified

42}
43
44func (r *FetchRequest) Decode(d PacketDecoder) error {
45 var err error
46 r.ReplicaID, err = d.Int32()
47 if err != nil {
48 return err
49 }
50 r.MaxWaitTime, err = d.Int32()
51 if err != nil {
52 return err
53 }
54 r.MinBytes, err = d.Int32()
55 if err != nil {
56 return err
57 }
58 // r.MaxBytes, err = d.Int32()
59 // if err != nil {
60 // return err
61 // }
62 topicCount, err := d.ArrayLength()
63 if err != nil {
64 return err
65 }
66 topics := make([]*FetchTopic, topicCount)
67 for i := range topics {
68 t := &FetchTopic{}
69 t.Topic, err = d.String()
70 if err != nil {
71 return err
72 }
73 partitionCount, err := d.ArrayLength()
74 if err != nil {
75 return err
76 }
77 ps := make([]*FetchPartition, partitionCount)
78 for j := range ps {
79 p := &FetchPartition{}
80 p.Partition, err = d.Int32()
81 if err != nil {
82 return err
83 }
84 p.FetchOffset, err = d.Int64()
85 if err != nil {
86 return err
87 }
88 p.MaxBytes, err = d.Int32()
89 if err != nil {
90 return err
91 }
92 ps[j] = p
93 }
94 t.Partitions = ps
95 topics[i] = t
96 }
97 r.Topics = topics
98 return nil
99}
100
101func (r *FetchRequest) Key() int16 {

Callers

nothing calls this directly

Calls 4

Int32Method · 0.65
ArrayLengthMethod · 0.65
StringMethod · 0.65
Int64Method · 0.65

Tested by

no test coverage detected