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

[WIP][ISSUE-3007][Improve] Introduce a premise utils to reduce conditions check and exceptions processing #3513

Closed
wants to merge 10 commits into from

Conversation

zhengkezhou1
Copy link
Contributor

What changes were proposed in this pull request

Issue Number: close #3007

Brief change log

Add a tool to unify pre-checking and throwing exceptions

Verifying this change

This change added tests and can be verified as follows:

  • Added Test to verify the change.

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): (no)

@zhengkezhou1 zhengkezhou1 changed the title [ISSUE-3007][Future] Introduce a premise utils to reduce conditions check and exceptions processing [ISSUE-3007][Improve] Introduce a premise utils to reduce conditions check and exceptions processing Jan 26, 2024
import java.util.Objects;

/** Determine whether to throw an exception based on the check condition */
public class PremisesUtils {
Copy link
Member

Choose a reason for hiding this comment

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

good job

@@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.streampark.console.base.domain;
package org.apache.streampark.common.domain;
Copy link
Member

Choose a reason for hiding this comment

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

hi,

Thanks for your contribution! It's a great improvement. However, from my perspective, there are a issue:

The common layer is a globally module where we strive to include common functionalities that are unrelated to specific business logic. Besides providing a data platform based on Spring Boot, StreamPark is also a stream processing development framework. We have provided some Flink|spark rapid development APIs, allowing users to independently leverage the capabilities of the development framework. Looking at it this way, it is not reasonable to place platform-specific logic such as HTTP status codes and backend exception message display in the common layer. These are not common capabilities, and they are not needed by the development framework.

@wolfboys
Copy link
Member

I really like this improvement and I'm looking forward to your next submit. 😊

@caicancai
Copy link
Member

I will start reviewing this PR if no one reviews it

@wolfboys
Copy link
Member

wolfboys commented Feb 5, 2024

In the current code, the backend still returns error messages to the frontend as before. The key issue is that these error messages are hard-coded and not processed through i18n. You can check out this issue. My suggestion is that after the backend detects an error, it should return a business state code, and the message info for each status code can be handled by the frontend.

@zhengkezhou1 zhengkezhou1 changed the title [ISSUE-3007][Improve] Introduce a premise utils to reduce conditions check and exceptions processing [WIP][ISSUE-3007][Improve] Introduce a premise utils to reduce conditions check and exceptions processing Feb 19, 2024
@caicancai
Copy link
Member

@RocMarshal If you have time, can you help me with the review? Thank you.

@zhengkezhou1
Copy link
Contributor Author

@RocMarshal @wolfboys I will replaced the hard-coded place in the project soon

@wolfboys
Copy link
Member

wolfboys commented Mar 9, 2024

hi:
There are some conflicts that need to be resolved first

@RocMarshal
Copy link
Contributor

In the current code, the backend still returns error messages to the frontend as before. The key issue is that these error messages are hard-coded and not processed through i18n. You can check out this issue. My suggestion is that after the backend detects an error, it should return a business state code, and the message info for each status code can be handled by the frontend.

+1 for me.

Hi @zzzk1 Thank you for the pr and sorry for the late reply.
thx for @wolfboys @caicancai comments.

How about

  • Only introduce a separate XXXUtils in console-service to perform a check with built-in exception binding
  • And keep common related checks in Utils.

?

I'd like to more ideas about it~

@wolfboys
Copy link
Member

In the current code, the backend still returns error messages to the frontend as before. The key issue is that these error messages are hard-coded and not processed through i18n. You can check out this issue. My suggestion is that after the backend detects an error, it should return a business state code, and the message info for each status code can be handled by the frontend.

+1 for me.

Hi @zzzk1 Thank you for the pr and sorry for the late reply. thx for @wolfboys @caicancai comments.

How about

  • Only introduce a separate XXXUtils in console-service to perform a check with built-in exception binding
  • And keep common related checks in Utils.

?

I'd like to more ideas about it~

  • Only introduce a separate XXXUtils in console-service to perform a check with built-in exception binding
  • And keep common related checks in Utils.

+1, This is a good idea

@RocMarshal RocMarshal closed this Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improve] Introduce a utils to process conditions check and exceptions thrown.
4 participants