-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Kafka message from stack to prevent allocations (#47)
* Get Kafka message from stack to prevent allocations * Fix unnecessary topic name calculation
- Loading branch information
Showing
5 changed files
with
30 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
package message | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
type KafkaMessage struct { | ||
Headers map[string]string | ||
Key []byte | ||
Value []byte | ||
} | ||
|
||
func GetKafkaMessage(key []byte, value []byte, headers map[string]string) *KafkaMessage { | ||
message := MessagePool.Get().(*KafkaMessage) | ||
message.Key = key | ||
message.Value = value | ||
message.Headers = headers | ||
return message | ||
} | ||
|
||
var MessagePool = sync.Pool{ | ||
New: func() any { | ||
return &KafkaMessage{} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters