ruanwenjun commented on issue #15183:
URL:
https://github.com/apache/dolphinscheduler/issues/15183#issuecomment-1827604594
> here are my thoughts, please give me some advice?@ruanwenjun
>
> 1. Split status according to different services
> ```java
> /*enum TaskStatus.java*/
> TASK_TIMEOUT_PARAMS_ERROR(10002, "task timeout parameter is not valid",
"任务超时参数无效")
>
> /*enum UserStatus.java*/
> USER_NAME_EXIST(10003, "user name already exists", "用户名已存在")
>
> /**enum DataSourceStatus.java*/
> DATASOURCE_EXIST(10015, "data source name already exists", "数据源名称已存在")
> ```
> 2. Abandon the putMsg() method in **BaseService** and implement the
**putMsg()** method according to the status split by different services.
>
> ```java
> /*ExecutorServiceImpl.java*/
>
> /**
> * put message to map
> *
> * @param result result code
> * @param taskStatus status
> * @param statusParams status message
> */
> private void putMsg(Map<String, Object> result, TaskStatus taskStatus,
Object... statusParams) {
> result.put(Constants.STATUS, taskStatus);
> if (statusParams != null && statusParams.length > 0) {
> result.put(Constants.MSG,
MessageFormat.format(taskStatus.getMsg(), statusParams));
> } else {
> result.put(Constants.MSG, taskStatus.getMsg());
> }
> }
> ```
>
> This method is intuitive, but requires changing a lot of code
A better way is change Status into a interface, keep the method getMsg and
getCode, only splite the enum into sub Enum which need to implement the `Status
`, then you don't need to change the code in the service in this pr.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]