pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] merlimat commented on a change in pull request #987: Add Type information to Pulsar client interface
Date Thu, 01 Jan 1970 00:00:00 GMT
merlimat commented on a change in pull request #987: Add Type information to Pulsar client
interface
URL: https://github.com/apache/incubator-pulsar/pull/987#discussion_r158401857
 
 

 ##########
 File path: pulsar-client/src/main/java/org/apache/pulsar/client/api/PulsarClient.java
 ##########
 @@ -73,7 +73,9 @@ public static PulsarClient create(String serviceUrl, ClientConfiguration
conf) t
      * @throws PulsarClientException.AuthorizationException
      *             if the authorization to publish on topic was denied
      */
-    Producer createProducer(String topic) throws PulsarClientException;
+    Producer<byte[]> createProducer(String topic) throws PulsarClientException;
+
+    <T> Producer<T> createProducer(String topic, Codec<T> codec) throws
PulsarClientException;
 
 Review comment:
   For example, I was thinking something like : 
   
   ```java
   class MyClass {
     public int x;
     public int y;
   }
   
   Producer<MyClass> producer = client.createProducer(topic,
                                          JSONSchema.of(MyClass.class));
   
   // or 
   Producer<MyClass> producer = client.createProducer(topic,
                                    AvroSchema.of(MyClass.class));
   ```
   Another syntax option:
   
   ```java
   Producer<MyClass> producer = client.createProducer(topic,
                                    Schema.Avro(MyClass.class));
   ```
   
   The key difference would be to always imply a schema (whether that is enforced or not in
server side is a different matter), rather that implying just the serder codec which will
be anyway specified by the schema.
   
   Of course, that would make it more difficult to use typed API with a custom codec (eg:
no avro/json or something natively supported), but I believe it's a better semantic overall.
   

----------------------------------------------------------------
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

Mime
View raw message