Replies: 1 comment 5 replies
-
I would, in general, recommend against exporting protocol features in the same package that the primary API usage is located. They are kind of cross-purpose, one being a thin-ish nearly transparent wrapper of the protocol, and the other a higher-level simple to use API. And having both exported in the same package would pollute godoc information with a mix of documentation for both purposes, meaning a simple API is buried in protocol details, and protocol details are littered with a high-level API design. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've got a use-case where I'd like to receive Kafka protocol messages, parse them and respond to them. Sarama seems like an obvious choice since it has many of the low-level primitives available for use in the source code.
However, I've found that Sarama seems to be more geared towards being a Kafka consumer/producer, and not towards acting as a broker - which is understandable since that is where the most users are. Much of the functionality needed in order to manipulate the Kafka protocol isn't available to users or Sarama due to not being exported.
By changing a few symbols to be exported, Sarama can successfully be used to decode, modify and encode Kafka protocol messages. I've got a fork with some fairly naive changes that allow for this here: https://github.com/MadsRC/sarama/commit/a86ff8547b4bd0c77d556ea2efcfc3f30c641d62
My idea would be for a new feature would be to make the Decode, Encode, request.CorrelationID and request.Body available to users of Sarama. One naive approach would be to just export them, but perhaps a better alternative is to have a low-level/protocol level subpackage of Sarama? Something that just makes the protocol primitives available for use, along with methods that allow for the encoding and decoding of these.
Beta Was this translation helpful? Give feedback.
All reactions