diff --git a/delete_groups_response.go b/delete_groups_response.go index 81c372e36..c067ebb42 100644 --- a/delete_groups_response.go +++ b/delete_groups_response.go @@ -1,12 +1,16 @@ package sarama +import ( + "time" +) + type DeleteGroupsResponse struct { - ThrottleTimeMs int32 + ThrottleTime time.Duration GroupErrorCodes map[string]KError } func (r *DeleteGroupsResponse) encode(pe packetEncoder) error { - pe.putInt32(r.ThrottleTimeMs) + pe.putInt32(int32(r.ThrottleTime / time.Millisecond)) if err := pe.putArrayLength(len(r.GroupErrorCodes)); err != nil { return err @@ -22,12 +26,11 @@ func (r *DeleteGroupsResponse) encode(pe packetEncoder) error { } func (r *DeleteGroupsResponse) decode(pd packetDecoder, version int16) error { - throttleTimeMs, err := pd.getInt32() + throttleTime, err := pd.getInt32() if err != nil { return err } - - r.ThrottleTimeMs = throttleTimeMs + r.ThrottleTime = time.Duration(throttleTime) * time.Millisecond n, err := pd.getArrayLength() if err != nil { diff --git a/delete_groups_response_test.go b/delete_groups_response_test.go index 855e305c8..6f622b5f0 100644 --- a/delete_groups_response_test.go +++ b/delete_groups_response_test.go @@ -30,7 +30,7 @@ func TestDeleteGroupsResponse(t *testing.T) { response = new(DeleteGroupsResponse) testVersionDecodable(t, "empty", response, emptyDeleteGroupsResponse, 0) - if response.ThrottleTimeMs != 0 { + if response.ThrottleTime != 0 { t.Error("Expected no violation") } if len(response.GroupErrorCodes) != 0 { @@ -39,7 +39,7 @@ func TestDeleteGroupsResponse(t *testing.T) { response = new(DeleteGroupsResponse) testVersionDecodable(t, "error", response, errorDeleteGroupsResponse, 0) - if response.ThrottleTimeMs != 0 { + if response.ThrottleTime != 0 { t.Error("Expected no violation") } if response.GroupErrorCodes["foo"] != ErrClusterAuthorizationFailed { @@ -48,7 +48,7 @@ func TestDeleteGroupsResponse(t *testing.T) { response = new(DeleteGroupsResponse) testVersionDecodable(t, "no error", response, noErrorDeleteGroupsResponse, 0) - if response.ThrottleTimeMs != 0 { + if response.ThrottleTime != 0 { t.Error("Expected no violation") } if response.GroupErrorCodes["foo"] != ErrNoError {