CallistoLabsNYC / samsa

Rust-native Kafka/Redpanda protocol and client implementation.
Apache License 2.0
106 stars 5 forks source link

feat: Create dedicated constructor method for tcp producer/consumer #104

Closed theelderbeever closed 1 week ago

theelderbeever commented 1 week ago

Adds methods for directly creating ProducerBuilder<TcpConnection> and ConsumerBuilder<TcpConnection> without needing to define the generic T: ConnConfig.

dhonig commented 1 week ago

@theelderbeever Thank you for your contribution! Can you provide a bit more on the context of why this is needed. Is this just to have a way to get low level access to the TCPConnection or am I missing something?

theelderbeever commented 1 week ago

@dhonig "needed" is probably an overstatement. It just represents and ease-of-use/high-level way of creating the underlying concrete type. After seeing the other variants of the BrokerConnection after looking at more examples it is probably not a great pattern to use so feel free to reject it!

dhonig commented 1 week ago

My instinct here is that things like this offer some convenience at the cost of ease of use and possibly complexity. I'm going to bite on your suggestion that this is probably not needed. If there is a concrete use case that necessitates this then we can re-consider. Thanks @theelderbeever! Look forward to your future contributions!

theelderbeever commented 1 week ago

@dhonig Yep totally understand. An easier and even less pervasive approach would likely just be exposing types anyway...

pub type TcpConsumerBuilder = ConsumerBuilder<TcpConnection>;

which then would be used like

let builder = TcpConsumerBuilder::new(...);

However, even that is ultimately not a necessary thing.