Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E399F200D85 for ; Fri, 22 Dec 2017 00:30:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E24F2160C2B; Thu, 21 Dec 2017 23:30:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 40F60160C2D for ; Fri, 22 Dec 2017 00:30:57 +0100 (CET) Received: (qmail 27269 invoked by uid 500); 21 Dec 2017 23:30:56 -0000 Mailing-List: contact commits-help@pulsar.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.incubator.apache.org Delivered-To: mailing list commits@pulsar.incubator.apache.org Received: (qmail 27200 invoked by uid 99); 21 Dec 2017 23:30:56 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Dec 2017 23:30:56 +0000 From: GitBox To: commits@pulsar.apache.org Subject: [GitHub] merlimat commented on a change in pull request #987: Add Type information to Pulsar client interface Message-ID: <151389905592.9774.4454913645499896768.gitbox@gitbox.apache.org> archived-at: Thu, 21 Dec 2017 23:30:58 -0000 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 createProducer(String topic) throws PulsarClientException; + + Producer createProducer(String topic, Codec codec) throws PulsarClientException; Review comment: For example, I was thinking something like : ```java class MyClass { public int x; public int y; } Producer producer = client.createProducer(topic, JSONSchema.of(MyClass.class)); // or Producer producer = client.createProducer(topic, AvroSchema.of(MyClass.class)); ``` Another syntax option: ```java Producer 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