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

feat UrlResolver #4546

Closed
wants to merge 2 commits into from
Closed

feat UrlResolver #4546

wants to merge 2 commits into from

Conversation

xmgdtc
Copy link

@xmgdtc xmgdtc commented Aug 21, 2024

1 use UrlResolver class to replace baseUrl string in ExternalTaskClientBuilder.class so that we can control how to get the address such as use load balance

@CLAassistant
Copy link

CLAassistant commented Aug 22, 2024

CLA assistant check
All committers have signed the CLA.

@danielkelemen
Copy link
Member

Hi @xmgdtc,

Thank you for opening a PR!
You need sign our CLA Contributor License Agreement in order to be able to contribute.

So this feature would make it possible to change the baseUrl dynamically without restarting the client. It makes sense, I will soon review your code changes and provide some feedback.

-Daniel

@xmgdtc
Copy link
Author

xmgdtc commented Aug 26, 2024

i have completed and signed this agreement thank you for your review

@tasso94 tasso94 requested review from PHWaechtler and removed request for danielkelemen December 4, 2024 10:36
@PHWaechtler
Copy link
Contributor

Hi @xmgdtc,
Thank you for raising this PR, I have taken over review from daniel and will be reviewing it in the next weeks. Before that though, I noticed there is a conflict in clients/java/client/src/main/java/org/camunda/bpm/client/impl/EngineClient.java, could you please resolve this before review?
Thanks,
Helene

@xmgdtc
Copy link
Author

xmgdtc commented Dec 5, 2024

The conflict has been resolved
Thanks

Copy link
Contributor

@PHWaechtler PHWaechtler left a comment

Choose a reason for hiding this comment

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

Hi again @xmgdtc,

Thanks again for your contribution! I have now reviewed it and left some comments for you. Most of them are just small spelling issues and two missing license headers, the main logical adjustment that needs made is to address the null/empty check for the baseURL here and my question regarding the correct class checked here.

Additionally to the comments, I have these requests:

  • You mentioned that you have signed the license agreement but that doesn't seem to have gone through as its still marked as unsigned, can you please have another look here and sign again?

  • Can you please add test coverage for this new implementation, note we have some testing best practices documented here

Once the comments and the above are implemented I will do another re review.
Thank you, and please let me know if you have any questions.
Helene

@@ -34,11 +34,45 @@ public interface ExternalTaskClientBuilder {
/**
* Base url of the Camunda BPM Platform REST API. This information is mandatory.
*
* if use this method, it will create a permanent url resolver with the given baseUrl
Copy link
Contributor

Choose a reason for hiding this comment

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

Small grammar improvement:

Suggested change
* if use this method, it will create a permanent url resolver with the given baseUrl
* If this method is used, it will create a permanent url resolver with the given baseUrl.

* @param baseUrl of the Camunda BPM Platform REST API
* @return the builder
*/
ExternalTaskClientBuilder baseUrl(String baseUrl);


/**
* url resovler of the Camunda BPM Platform REST API. This information is mandatory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo:

Suggested change
* url resovler of the Camunda BPM Platform REST API. This information is mandatory.
* Url resolver of the Camunda BPM Platform REST API. This information is mandatory.

/**
* url resovler of the Camunda BPM Platform REST API. This information is mandatory.
*
* if the server is ther cluster or you are using spring cloud. you can create a class implements UrlResolver
Copy link
Contributor

Choose a reason for hiding this comment

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

Grammar/Spelling improvements:

Suggested change
* if the server is ther cluster or you are using spring cloud. you can create a class implements UrlResolver
* If the server is in a cluster or you are using spring cloud, you can create a class which implements UrlResolver.

package org.camunda.bpm.client;

/**
* get service url from camunda server
Copy link
Contributor

Choose a reason for hiding this comment

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

Small:

Suggested change
* get service url from camunda server
* Get service url of the Camunda server

Comment on lines 60 to 62



Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 Nit: we can reduce these newlines

Comment on lines +238 to +241
if (this.urlResolver instanceof PermanentUrlResolver) {
((PermanentUrlResolver) this.urlResolver).setBaseUrl(sanitizeUrl(this.urlResolver.getBaseUrl()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ According to the javadoc added above, I believe we're expecting urlResolver to be an instance of UrlResolver, not necessarily PermanentUrlResolver. Can we please adjust this check accordingly, or let me know if I'm misunderstanding 🤔

Copy link
Author

Choose a reason for hiding this comment

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

On branch master this method is like blow,i thought it is used for replacing "/" from the baseUrl. but when useing random loadbalance we can`t fight out all the urls. so i kept the logic, when it is a permanent address, still call this method. if not ,developer should resolve by themself

protected void initBaseUrl() {
baseUrl = sanitizeUrl(baseUrl);
}

protected String sanitizeUrl(String url) {
url = url.trim();
if (url.endsWith("/")) {
url = url.replaceAll("/$", "");
url = sanitizeUrl(url);
}
return url;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, so this is just the default sanitation when using the PermanentUrlResolver right?

Copy link
Author

Choose a reason for hiding this comment

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

Yes i kept this logic so that the people who using the regular baseUrl String won`t need to change anything

import org.camunda.bpm.client.UrlResolver;

/**
* urlResolver with permanent address
Copy link
Contributor

Choose a reason for hiding this comment

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

🔧 Nit

Suggested change
* urlResolver with permanent address
* UrlResolver with permanent address

*
* this is a sample for spring cloud DiscoveryClient
*
* public class CustomUrlResolver implements UrlResolver{
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Nice to have an example included here

@@ -0,0 +1,9 @@
package org.camunda.bpm.client;
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is missing the licenseHeader, can you please add it to the top of this file. You can copy it from one of the other files

@@ -0,0 +1,24 @@
package org.camunda.bpm.client.impl;
Copy link
Contributor

Choose a reason for hiding this comment

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

This file also needs the license header added to it

@xmgdtc
Copy link
Author

xmgdtc commented Dec 19, 2024

@PHWaechtler I finished fixing spilling and licenseHeaders. sorry for my bad english. i tried to write a test method. but unfortunately i can`t download all the dependencies with my internet . so i am not sure this test works. but i try this code in my project and it is works

@PHWaechtler
Copy link
Contributor

Hi again @xmgdtc,
Thanks for implementing the changes 🙏
Before I do the re review I noticed why the CLA license agreement is not marked as signed. I saw you are using two different accounts: the initial commit was made by mxl1909 yet the other commits and the PR was created with user xmgdtc and the CLA is not signed formxl1909. I think the easiest way to remedy this is for you to adjust the commit history on this branch to only include commits from xmgdtc (you can just squash them into one if you like) then you only have to sign the CLA with xmgdtc. Can you please do this as otherwise we cannot merge the PR without a signed CLA.

@PHWaechtler
Copy link
Contributor

PHWaechtler commented Jan 7, 2025

Hi @xmgdtc , just pinging again to make sure you saw this request. Please have a look so that the CLA can be signed, otherwise we cannot progress with this PR. Thans!

xmgdtc added 2 commits January 8, 2025 10:28
…ss so that we can use load balance address
# Conflicts:
#	clients/java/client/src/main/java/org/camunda/bpm/client/impl/EngineClient.java
@xmgdtc
Copy link
Author

xmgdtc commented Jan 8, 2025

Hi @PHWaechtler , I rebased and commited again. Sorry for keep you waiting for so long beacuse i got a fever last week .

@PHWaechtler
Copy link
Contributor

Hi @xmgdtc ,
no worries I hope you feel better, and thanks for signing. I reviewed the changes and found a couple more things for adjustment - since you mentioned you had issues with the test/dependencies and your internet I went ahead and applied the changes on a duplicate branch here. Since that is a new PR it will require an additional review from another member of our team, I will reach out about this internally and assign one soon. If you have any comments or questions please let me know. Once its approved we will merge the changes
Thanks again for your contribution
Helene

@PHWaechtler
Copy link
Contributor

Hi @xmgdtc, just writing to let you know we have reviewed merged the PR with your feature so I will close this one now. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants