Skip to content

Commit

Permalink
Added comment about preferring hamba/avro
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartboyd119 committed Sep 24, 2024
1 parent c810f7d commit 3ddc721
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/producer_avro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func main() {
log.Panic(err)
}
for {
// The DummyEvent type is generated using `hamba/avro` (see make). This is the preferred generation for
// `formatter=zkafka.AvroSchemaRegistry` because the underlying serializer uses the avro tags on the generated struct
// // to properly connect the schema and struct
event := DummyEvent{
IntField: rand.Intn(100),
StringField: randomNames[rand.Intn(len(randomNames))],
Expand Down
4 changes: 4 additions & 0 deletions example/worker_avro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func main() {
func Process(_ context.Context, msg *zkafka.Message) error {
// sleep to simulate random amount of work
time.Sleep(100 * time.Millisecond)

// The DummyEvent type is generated using `hamba/avro` (see make). This is the preferred generation for
// `formatter=zkafka.AvroSchemaRegistry` because the underlying deserializer uses the avro tags on the generated struct
// to properly connect the schema and struct
event := DummyEvent{}
err := msg.Decode(&event)
if err != nil {
Expand Down

0 comments on commit 3ddc721

Please sign in to comment.