justinmclean opened a new issue, #4694:
URL: https://github.com/apache/iggy/issues/4694

   ### Description
   
   The Rust, Node, Java and C# examples show the message envelope pattern, 
where each payload is wrapped in a JSON object with a `message_type` and a 
`payload` string so one topic can carry several message kinds. The Go examples 
have only `getting-started` and `reader-consumer`.
   
   ### Affected area / component
   
   Go examples
   
   ### Proposed solution
   
   Add `examples/go/message-envelope/producer/main.go` and 
`examples/go/message-envelope/consumer/main.go`, and a "Message Envelopes" 
section in `examples/go/README.md`.
   
   - Reuse the flag handling, connection set-up and stream and topic creation 
from `examples/go/getting-started/producer/main.go` and `consumer/main.go`.
   - Copy the order types (`OrderCreated`, `OrderConfirmed`, `OrderRejected`) 
and the envelope shape from `examples/node/src/message-envelope/`.
   - The producer marshals each envelope with `encoding/json` and sends five 
batches of ten to partition 0.
   - The consumer polls, unmarshals the envelope, switches on `message_type` 
and decodes `payload` into the matching struct. An unknown type is logged, not 
a crash.
   
   Message headers are out of scope, because the Go SDK has no typed header 
builder yet.
   
   **How to test:** start a fresh server (`cargo run --bin iggy-server -- 
--fresh --with-default-root-credentials`), run `go run 
./message-envelope/producer/main.go` and then `go run 
./message-envelope/consumer/main.go` in `examples/go`, and check `go vet ./...` 
passes. CI runs the commands listed in the README through 
`scripts/run-examples-from-readme.sh`.
   
   ### Good first issue
   
   - [x] I think this could be a good first issue for a new contributor
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to