Skip to content

Commit

Permalink
Added version to broker.encode()
Browse files Browse the repository at this point in the history
  • Loading branch information
mimaison committed Feb 13, 2018
1 parent 835ee89 commit 2e5395b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (b *Broker) decode(pd packetDecoder, version int16) (err error) {
return nil
}

func (b *Broker) encode(pe packetEncoder) (err error) {
func (b *Broker) encode(pe packetEncoder, version int16) (err error) {

host, portstr, err := net.SplitHostPort(b.addr)
if err != nil {
Expand All @@ -644,6 +644,13 @@ func (b *Broker) encode(pe packetEncoder) (err error) {

pe.putInt32(int32(port))

if version >= 1 {
err = pe.putNullableString(b.rack)
if err != nil {
return err
}
}

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions find_coordinator_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (f *FindCoordinatorResponse) decode(pd packetDecoder, version int16) (err e
}

coordinator := new(Broker)
if err := coordinator.decode(pd); err != nil {
if err := coordinator.decode(pd, 0); err != nil {
return err
}
if coordinator.addr == ":0" {
Expand All @@ -60,7 +60,7 @@ func (f *FindCoordinatorResponse) encode(pe packetEncoder) error {
}
}

if err := f.Coordinator.encode(pe); err != nil {
if err := f.Coordinator.encode(pe, 0); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion metadata_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (r *MetadataResponse) encode(pe packetEncoder) error {
return err
}
for _, broker := range r.Brokers {
err = broker.encode(pe)
err = broker.encode(pe, r.Version)
if err != nil {
return err
}
Expand Down

0 comments on commit 2e5395b

Please sign in to comment.