GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — PIP-12 Introduce builder for creating Producer Consumer Reader by merlimat · Pull Request #1089 · apache/pulsar Conversation
Contributor
MotivationFull context at Modifications
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
sijie
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the proposed api looks good me. but it seems some of the javadocs were copied from configuration based methods, we need to update the javadoc for those methods.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. documentation seems need to be updated
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, this was just a placeholder. I'll clean up all Javadocs when submitting final PR.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
mgodave
approved these changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: since this is a builder, do we want to go with the canonical 'build' terminology instead?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I was debating about this. My reasoning here was to differentiate the actions: client.newProducer().topic(MY_TOPIC).create(); // versus client.newConsumer().topic(MY_TOPIC).subscriptionName(MY_SUB).subscribe(); Subscribe here implies to create a durable I'm not 100% settled on this. Please anyone share opinions ;)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like having async and sync versions cloud things. The nature of the library is that it is async and if all we are doing is calling
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think most users still reasons in term of "sync" API, especially for creating the producer/consumer (compared to publishing messages).
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
merlimat
force-pushed
the
builder-api
branch
from
f5ee1fe to
f17cac1
Compare
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
Yes, the idea was to have different ways to specify: // Single topic client.newConsumer().topic(MY_TOPIC).subscriptioName(SUB).build(); // List of topics List<String> myList = ...; client.newConsumer().topics(myList).subscriptioName(SUB).build(); // Regex client.newConsumer().topicsRegex("test.*").subscriptioName(SUB).build(); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
the change looks good to me. some minor comments.
it is a really awesome change to move the api to builder pattern!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: it might be good to add "@SInCE 2.0". so we can track when we introduce the build methods.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure, will add @since
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: @Override?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
clone() is a bit weird in the way it's treated. It cannot be marked as @Override
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
incomplete comment?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ups, forgot to finish
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@return a consumer?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
the param field seems to be wrong?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's just an idea but we may want to pass a Topic object instead of its string representation. Then this interface would be freed to define a format of topic name string (persistent://.../.../...), and users can manage their topic names in any format.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would leave it as a string, at least for now, because that would be a bigger change I think. We're already trying to address the long topic names by having some degree of implicitenes. See https://github.com/apache/incubator-pulsar/wiki/PIP-10:-Remove-cluster-for-namespace-and-topic-names and https://github.com/apache/incubator-pulsar/wiki/PIP-11:-Short-topic-names
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Alright. Yeah, and the change is not necessary for introducing builders.
Below is what I thought.
We should probably introduce a parser for topic name string to reduce duplicate parsing code. Otherwise PIP-10 and PIP-11 would be tough because we need to modify all parsing code here and there. If we introduce the parser, the builder implementation would be like:
public ConsumerBuilder topic(String topicName) { this.topic = Topic.parse(topicName); return this; }
The Topic class would be like this:
class Topic { public Topic(String topicName) { // parse ... this.namespace = .... this.cluster = ... ... } public getNamespace() { return this.namespace; } ... }
Once we did this, other components that use Topic object wouldn't need to care how the object was created. And if so, it might be useful if users could create own Topic implementation and pass it to builders.
So I'm not saying we should eliminate the Pulsar topic URL format. I just thought using Topic object may increase its capability.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For parsing, it's already all concentrated in the DestinationName class, which I plan to rename into TopicName. It is not exposed to users though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
How about "allowTlsInsecureConnection"?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure, with the builder it makes sense a more "imperative" style
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"TLS"? or "Tls"? Need consistency.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll go back back to "Tls"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
missing a parameter name
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
retest this please |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
585dd9b to
03dcd22
Compare
|
Rebased to fix tls test certificates issue |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Since the apache#1089,the interface 'org.apache.pulsar.client.api.PulsarClient' has supported builder for consumer and producer. And,int the apache#3272, some deprecated client API have been removed including 'public static PulsarClient create(String serviceUrl)','Consumer<byte[]> subscribe(String topic, String subscription)' and 'Producer<byte[]> createProducer(String topic)'. So, I modified the example with the current version of the interface.
* Update concepts-messaging.md Since the #1089,the interface 'org.apache.pulsar.client.api.PulsarClient' has supported builder for consumer and producer. And,int the #3272, some deprecated client API have been removed including 'public static PulsarClient create(String serviceUrl)','Consumer<byte[]> subscribe(String topic, String subscription)' and 'Producer<byte[]> createProducer(String topic)'. So, I modified the example with the current version of the interface. * Apply suggestions from code review Specify message schema Co-Authored-By: Matteo Merli <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.