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

Rename and deprecate Zeebe classes #19639

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

nicpuppa
Copy link
Contributor

@nicpuppa nicpuppa commented Jun 21, 2024

Description

With this PR all the Zeebe.... classes are replaced or deprecated in favor of more general classes.

Related issues

closes #19485
closes #19488

@nicpuppa nicpuppa requested a review from tmetzke June 21, 2024 12:56
@github-actions github-actions bot added the component/zeebe Related to the Zeebe component/team label Jun 21, 2024
@nicpuppa nicpuppa marked this pull request as draft June 21, 2024 13:00
@nicpuppa
Copy link
Contributor Author

Sorry for the big amount of files @tmetzke, let me know if you want to review it in a pairing session. I tried to divide the changes into separate commits (was hard 🤣)

@nicpuppa nicpuppa marked this pull request as ready for review June 21, 2024 13:57
ZeebeFuture<T> send();

CamundaFuture<T> sendCommand();
Copy link
Member

Choose a reason for hiding this comment

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

❓ This will mean a lot of code changes for users, I guess? Do we really need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this method to not make users change their code. Because I can't change/override the return type of the send method

Copy link
Member

Choose a reason for hiding this comment

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

Oh, yeah, I see. Well, that's a bit tricky 🤔
I'll try to find some time to think about it again.

Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this again, I would still like to avoid introducing this new method.
What happens if we return a CamundaFuture from the send method here and the CamundaFuture extends the ZeebeFuture?
If I currently have a variable final ZeebeFuture result, the send method should still work, shouldn't it? I now receive a CamundaFuture but that is just a specialized ZeebeFuture, it still fits into the ZeebeFuture and my code should still be fine. I'll still only have access to the ZeebeFuture-part of the return CamundaFuture but that should be OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not doable. CamundaFuture extends ZeebeFuture, if we change the return type also users might need to do that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me try

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems not working as expected

Copy link
Contributor Author

@nicpuppa nicpuppa Jun 27, 2024

Choose a reason for hiding this comment

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

Oh because tasklist is using mockito on the return type. So if users have implemented some tests and they stub the return type they need to adjust them. This is not something that we want now @tmetzke

Copy link
Member

Choose a reason for hiding this comment

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

OK, I see the issue. It is a breaking change for sure since we're adjusting the return type of the method.
Well, I guess, if we want to stay backward-compatible, we'll have to introduce a new method 😞
Sorry for the noise and additional work. We can also represent it on Monday again in the team and ask for feedback but I think there aren't many ways around it...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will rollback the changes, and raise it to the team

Comment on lines 98 to 105
public <HttpT, RespT> void get(
final String path,
final RequestConfig requestConfig,
final Class<HttpT> responseType,
final JsonResponseTransformer<HttpT, RespT> transformer,
final HttpCamundaFuture<RespT> result) {
sendRequest(Method.GET, path, null, requestConfig, responseType, transformer, result);
}
Copy link
Member

Choose a reason for hiding this comment

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

💭 I am wondering: should we tackle the "extends" mechanism the other way around, i.e. HttpZeebeFuture extends HttpCamundaFuture?

More details:

  • All implementation code sits in the new Camunda... classes and moves from the io.camunda.zeebe.client package to io.camunda.client.
  • All Zeebe... classes would extend the Camunda classes so they still exist for easier migration. If Zeebe classes are not needed externally, we don't extend the respective Camunda classes.
  • Under the hood, all code already works with Camunda classes.
  • With 8.8, we can remove the io.camunda.zeebe.client package in one swoop, no further adjustments should be necessary.
  • Methods like those in the HttpClient could be called with a HttpCamundaFuture or HttpZeebeFuture. The method signature changes to use the HttpCamundaFuture. A deprecated HttpZeebeFuture could be handed in since it fulfills the contract, i.e. it is a HttpCamundaFuture.

I might overlook something that makes the transition for people harder, of course 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try to follow this approach and let you know 👍

Copy link
Contributor Author

@nicpuppa nicpuppa Jun 24, 2024

Choose a reason for hiding this comment

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

It seems more complex then I thought. I got stuck migrating/renaming the clients implementation and all related interfaces

Copy link
Member

Choose a reason for hiding this comment

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

I was fearing that would happen, yeah 🙈

Copy link
Member

@tmetzke tmetzke Jun 27, 2024

Choose a reason for hiding this comment

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

Let's keep the "extends" definitions as they are.
For the client here, to avoid duplicating methods, you could also write them as follows, I believe:

  public <HttpT, RespT, FutureT extends HttpZeebeFuture<RespT>> void get(
      final String path,
      final RequestConfig requestConfig,
      final Class<HttpT> responseType,
      final JsonResponseTransformer<HttpT, RespT> transformer,
      final FutureT result) {
    sendRequest(Method.GET, path, null, requestConfig, responseType, transformer, result);
  }

The crucial part would be the FutureT extends HttpZeebeFuture<RespT> type definition and using that as the type for the result parameter.
That way, you can hand in HttpCamundaFuture and HttpZeebeFuture.

Copy link
Member

Choose a reason for hiding this comment

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

Keeping the deprecated methods and adding the ones for the new type work just as well, of course. However, since this is an internal class, I was wondering if we actually need to keep the deprecated methods at all or if we can simply adjust all calling methods and use the new HttpCamundaFuture there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it make more sense to just use the old methods with HttpCamundaFuture

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like the cleanest solution, if possible.

@nicpuppa nicpuppa force-pushed the 19485-rename-zeebe-classes branch 2 times, most recently from f085e8f to 427d498 Compare June 27, 2024 08:51
@nicpuppa nicpuppa requested a review from tmetzke June 27, 2024 08:57
@@ -15,32 +15,37 @@
*/
package io.camunda.zeebe.client.api.command;
Copy link
Member

Choose a reason for hiding this comment

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

❓ At some point, we need to move this class to the new package name as well. Better we do that now, I guess? Can this be considered a breaking change? 🙈

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 going to be a breaking change, so it is not doable now

Copy link
Member

Choose a reason for hiding this comment

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

So, we're introducing the breaking change with 8.8 then?

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 the plan I think

this.preferRestOverGrpc = preferRestOverGrpc;
return this;
}

@Override
public ZeebeClient build() {
public CamundaClient build() {
Copy link
Member

Choose a reason for hiding this comment

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

❓ Just wondering: is this less of a breaking change for users than returning a CamundaFuture instead of a ZeebeFuture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I think we need to take the same approach used for the command here. Creating a new method with a different return type

Copy link
Member

Choose a reason for hiding this comment

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

We could also let the Zeebe... classes simply still return their Zeebe... counterparts wherever possible to be as minimally invasive as possible. Then we should only have very few points where it "collides" (e.g. FinalCommandStep).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, just duplicate the code here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like:

public final class CamundaClientBuilderImpl implements
    CamundaClientBuilder, CamundaClientConfiguration 

and

@Deprecated
public class ZeebeClientBuilderImpl implements ZeebeClientBuilder, ZeebeClientConfiguration 

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I was also just thinking:
Can we simply duplicate the code completely into the io.camunda.client package, rename everything there and at the critical conversion points take care of having both and handle it accordingly. With 8.8, we simply remove the io.camunda.zeebe.client package, rename the conversion point classes like FinalCommandStep, and remove their deprecated methods like send().

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit ugly for now and for patching later though, as the code is duplicated completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave this as an open point for Monday's team meeting. Deeper we go, deeper I'm thinking about just duplicating everythin 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/zeebe Related to the Zeebe component/team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a new CamundaClientBuilder Rename all the class related to Zeebe
2 participants