Skip to content

[app-builder] 优化部分性能,添加流程数据定时清理机制#21

Closed
FUNK6666 wants to merge 6 commits intoModelEngine-Group:mainfrom
FUNK6666:main
Closed

[app-builder] 优化部分性能,添加流程数据定时清理机制#21
FUNK6666 wants to merge 6 commits intoModelEngine-Group:mainfrom
FUNK6666:main

Conversation

@FUNK6666
Copy link
Copy Markdown
Contributor

@FUNK6666 FUNK6666 commented Apr 8, 2025

1、添加流程数据定期清理机制
2、更改waterflow中条件表达式执行时uuid生成规则,提升性能
3、添加缓存,提升对话性能

@CodeCasterX CodeCasterX changed the title [appengine] 优化部分性能,添加流程数据定时清理机制 [app-builder] 优化部分性能,添加流程数据定时清理机制 Apr 8, 2025
@CodeCasterX CodeCasterX self-assigned this Apr 8, 2025
@CodeCasterX CodeCasterX added in: builder Issues in app-builder modules type: enhancement A general enhancement labels Apr 8, 2025
@CodeCasterX CodeCasterX added this to Nova Apr 8, 2025
@CodeCasterX CodeCasterX added this to the 20250630 milestone Apr 8, 2025
/**
* 用于缓存app_id和meta的关系
*/
public static final Cache<String, Meta> AIPP_ID_LAST_META_CACHE = Caffeine.newBuilder()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image
  1. 该缓存命名不明确,其中 LAST 是什么意思?
  2. 该缓存是不是应该把访问权限收归到 private,然后仅通过方法来访问?而不是公开了之后支持任意访问
  3. 该缓存的注释需要调整,详细说清楚到底缓存了什么内容。

* 用于获取flowdefinition的缓存
*
* @param flowsService 操作flow的service
* @param flowsService 操作flow的service
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

注释风格需要全团队统一,采用代码仓库提供的格式化文件,不需要参数注释对齐,同时注释需要采用统一风格。这里可以改成如下:

/**
     * 通过缓存获取指定的已发布流程。
     *
     * @param flowsService 表示流程服务的 {@link FlowsService}。
     * @param flowDefinitionId 表示流程定义的唯一标识的 {@link String}。
     * @param context 表示操作上下文的 {@link OperationContext}。
     * @return 表示缓存流程信息的 {@link FlowInfo}。
     */

private static Meta getLatestMetaByAppId(MetaService metaService, String appId, OperationContext context) {
List<Meta> metas = MetaUtils.getAllMetasByAppId(metaService, appId, context);
if (CollectionUtils.isEmpty(metas)) {
throw new AippException(AippErrCode.APP_CHAT_DEBUG_META_NOT_FOUND);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

这里抛出异常的时候无日志,也没有将必要的参数信息透出,会对定位问题造成困扰。

if (isDebug) {
return getLatestMetaByAppId(metaService, appId, context);
}
// get一个aipp_id的缓存,然后根据aipp_id查询最新发布版的meta
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

如果要进行行内注释,需要写清楚,尽量不要中英文混杂,同时,团队统一规范,最后加上全角句号

private Context context;

/**
* 判断是否有@应用
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

注释风格统一,且需要写明确,不要存在简写

import java.util.concurrent.ThreadLocalRandom;

/**
* Uuid的Utils类。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

注释调整,同时 @since 后面需要跟创建该文件的时间,格式为 yyyy-MM-dd

*/
@Scheduled(strategy = Scheduled.Strategy.CRON, value = "0 0 3 * * ?")
@Transactional
public void cleanContextSchedule() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

该方法识别为重点方法,逻辑看样子存在数据库的访问删除操作,且每次操作都和当前操作时间有关,因为使用的是定时任务,当多实例并发时,就会产生并发数据库删除,当前还存在事务,是否在并发场景下该逻辑是有效的?请仔细分析,将分析结果写在注释上,方便后续维护。

* 包括成功、失败、终止的流程数据
*
* @author 杨祥宇
* @since 2025/04/02
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

注释风格是时间需要保持团队统一

@FUNK6666 FUNK6666 closed this Apr 10, 2025
@github-project-automation github-project-automation bot moved this to Done in Nova Apr 10, 2025
@FUNK6666 FUNK6666 reopened this Apr 10, 2025
@FUNK6666 FUNK6666 closed this Apr 10, 2025
@CodeCasterX CodeCasterX removed this from Nova Apr 10, 2025
@CodeCasterX CodeCasterX removed this from the 20250630 milestone Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: builder Issues in app-builder modules type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants