Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove rack from FindCoordinatorResponse #1051

Merged
merged 1 commit into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions find_coordinator_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func (f *FindCoordinatorResponse) decode(pd packetDecoder, version int16) (err e
}

coordinator := new(Broker)
if err := coordinator.decode(pd, version); err != nil {
// The version is hardcoded to 0, as version 1 of the Broker-decode
// contains the rack-field which is not present in the FindCoordinatorResponse.
if err := coordinator.decode(pd, 0); err != nil {
return err
}
if coordinator.addr == ":0" {
Expand Down Expand Up @@ -66,7 +68,7 @@ func (f *FindCoordinatorResponse) encode(pe packetEncoder) error {
if coordinator == nil {
coordinator = NoNode
}
if err := coordinator.encode(pe, f.Version); err != nil {
if err := coordinator.encode(pe, 0); err != nil {
return err
}
return nil
Expand Down
4 changes: 0 additions & 4 deletions find_coordinator_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

func TestFindCoordinatorResponse(t *testing.T) {
errMsg := "kaboom"
brokerRack := "foo"

for _, tc := range []struct {
desc string
Expand Down Expand Up @@ -38,7 +37,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
Coordinator: &Broker{
id: 7,
addr: "host:9092",
rack: &brokerRack,
},
},
encoded: []byte{
Expand All @@ -48,7 +46,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
0, 0, 0, 7, // Coordinator.ID
0, 4, 'h', 'o', 's', 't', // Coordinator.Host
0, 0, 35, 132, // Coordinator.Port
0, 3, 'f', 'o', 'o', // Coordinator.Rack
},
}, {
desc: "version 0 - error",
Expand Down Expand Up @@ -79,7 +76,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
255, 255, 255, 255, // Coordinator.ID: -1
0, 0, // Coordinator.Host: ""
255, 255, 255, 255, // Coordinator.Port: -1
255, 255, // Coordinator.Rack: empty
},
}} {
testResponse(t, tc.desc, tc.response, tc.encoded)
Expand Down