Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide separate module with Pulsar v1 client API wrapper #3228

Merged
merged 3 commits into from
Dec 30, 2018

Conversation

merlimat
Copy link
Contributor

Motivation

Provide a Pulsar V1 API compatibility wrappers.

Applications can use artifact name pulsar-client-1x instead of pulsar-client and this will allow us to drop the deprecated methods from pulsar-client.

@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Dec 20, 2018
@merlimat merlimat added this to the 2.3.0 milestone Dec 20, 2018
@merlimat merlimat self-assigned this Dec 20, 2018
@merlimat merlimat force-pushed the separate-api-from-impl branch from 07f6222 to 1f4596a Compare December 21, 2018 00:22
@merlimat
Copy link
Contributor Author

run integration tests

@jerrypeng
Copy link
Contributor

looks good to me

import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.client.api.PulsarClientException;

public class ConsumerV1Impl implements Consumer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if package name already has v1 then we should not add V1 into class name and it's better to keep ConsumerImpl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid confusion in the IDE with classes with same name in different namespaces

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to avoid confusion in the IDE with classes with same name in different namespaces

Umm.. I don't think it creates confusion and it's better to continue the same name with version(v1,v2) present into namespace.

<relativePath>..</relativePath>
</parent>

<artifactId>pulsar-client-2x-shaded</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is confusing. pulsar-client-1x-base has child module pulsar-client-2x-shaded ? client-2.x already has separate module at parent level. Shouldn't we need pulsar-client-1x-shaded ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I'm trying to solve here is that pulsar-client-1x is a wrapper over pulsar-client. At the same time, we have some interfaces that need to be duplicated in pulsar-client-1x (because the 2.x version will be different).

So, pulsar-client-2x-shaded is really pulsar-client but with just few interfaces renamed (eg: PulsarClient, Producer, Consumer and Reader) to avoid conflicts with the 1.x API.

So, although confusing, pulsar-client-2x-shaded is really the correct name and this module is not meant for direct usage anyway.

Copy link
Contributor

@rdhabalia rdhabalia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It raises few questions for the clients who are using V1 api and not ready to move V2 yet but still want to use new features.

  1. are we going to maintain this V1 api artifact with the new configuration changes?
  2. it will enforce client app to change artifact dependency else their existing app will fail.

So, instead can't we keep this api into the same pulsar-client artifact because anyway it doesn't have many classes and it will be easy to maintain if we have everything under one location.

@merlimat
Copy link
Contributor Author

It raises few questions for the clients who are using V1 api and not ready to move V2 yet but still want to use new features.

In every system you need to expect to upgrade and follow newer best practices in order to use new features. That is unrelated to the compatibility of older client library which is out of question.

  1. are we going to maintain this V1 api artifact with the new configuration changes?

Anyone interested in adding the new features in the v1 API can still update the 1x wrapper and add them. It will be trivial to do so.

  1. it will enforce client app to change artifact dependency else their existing app will fail.

An application is not "forced" to upgrade the artifact dependency.

It might want to upgrade to get new bug or security fixes. In that case it will have to update the Maven dependency (the version, at least). If the application is using the v1 API, it will have to switch to use pulsar-client-1x instead of pulsar-client. This will be clearly documented.

To summarize:

  1. The upgrade is not required
  2. If you want to upgrade version, also change artifact id.

So, instead can't we keep this api into the same pulsar-client artifact because anyway it doesn't have many classes and it will be easy to maintain if we have everything under one location.

The purpose of marking API methods as "Deprecated" is to give a warning and remove them in the future.

The current state of things is very confusing because we have 2 sets of APIs that a user have to chose from. This adds a lot to the knowledge required to get started with the API.

There are additional issue in the current state:

  • Because of shading, we're not able to attach javadoc and source jars to pulsar-client. The result is that developers cannot get javadoc in the IDE when using pulsar-client.
  • To achieve that, we need to separate pulsar-client and pulsar-client-api. pulsar-client-api will just contain the interfaces (and not be shaded).

Older API has a mix of interfaces and POJO which access concrete classes in other package. That kind of derailed over time and this is a way to fix that, do the cleanup and expose a very clean API surface.

@jerrypeng
Copy link
Contributor

@merlimat agreed

Copy link
Contributor

@jerrypeng jerrypeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@merlimat merlimat merged commit 742ee7e into apache:master Dec 30, 2018
merlimat added a commit to merlimat/pulsar that referenced this pull request Dec 31, 2018
merlimat added a commit that referenced this pull request Jan 5, 2019
* After #3228, removed usages of deprecated client API

* Removed ProducerConfiguration from flink connector

* Use pulsar-client-1x in pulsar-spark

* Fixed log4j adapter

* Fixed flink examples

* Fixed storm integration tests

* Fixed storm example

* Wrapping message listeners in v1 lib wrapper

* Fixed unit tests

* Moved spark receiver test to test-containers to avoid shading issues

* Fixed PulsarAvroTableSinkTest

* Only run spark receiver test in integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants