You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2017/12/19 20:16:03 UTC
[GitHub] sijie commented on issue #987: Add Type information to Pulsar client interface
sijie commented on issue #987: Add Type information to Pulsar client interface
URL: https://github.com/apache/incubator-pulsar/pull/987#issuecomment-352873899
A few thoughts:
- There can be binary BC concerns for existing 0.1.x pulsar users. However I think the new interface enforces type information and can easily support existing producers with an identical codec: `byte[] -> byte[]`. It might be worthing breaking binary BC for 0.2.x pulsar releases.
- I think `PulsarClient` doesn't have to be typed. The type information is associated with topics, and can be enforced at Producers and Consumers. You can do followings:
```
public interface PulsarClient {
<T> Producer<T> createProducer(..., Codec<T> codec);
<T> Consumer<T> createConsumer(..., Codec<T> codec);
}
```
- I think `Codec<T>` can be more gc-friendly with ByteBuf and InputStream.
```
public interface Codec<T> {
byte[] encode(T value);
T decode(byte[] bytes);
ByteBuf encodeBuf(T value);
T decodeBuf(ByteBuf buffer);
void encode(T value, OutputStream os);
T decode(InputStream is);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services