Skip to content

Commit

Permalink
Add Stats.Bytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Apr 18, 2024
1 parent f0d709f commit e3edc2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions kafka/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (e Stats) String() string {
return e.statsJSON
}

func (e Stats) Bytes() []byte {
return []byte(e.statsJSON)
}

// AssignedPartitions consumer group rebalance event: assigned partition set
type AssignedPartitions struct {
Partitions []TopicPartition
Expand Down
2 changes: 1 addition & 1 deletion kafka/stats_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func handleStatsEvent(t *testing.T, eventCh chan Event, statsReceived chan bool)

// test if the stats string can be decoded into JSON
var raw map[string]interface{}
err := json.Unmarshal([]byte(e.String()), &raw) // convert json to map
err := json.Unmarshal(e.Bytes(), &raw) // convert json to map
if err != nil {
t.Fatalf("json unmarshall error: %s", err)
}
Expand Down

0 comments on commit e3edc2b

Please sign in to comment.