chore: initialize qiming workspace repository
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>app-platform-log</artifactId>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>app-platform-log-application</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>system-sdk</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>app-platform-log-domain</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>app-platform-log-infra</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.xspaceagi.log.app.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xspaceagi.log.sdk.request.DocumentSearchRequest;
|
||||
import com.xspaceagi.log.sdk.service.ILogRpcService;
|
||||
import com.xspaceagi.log.sdk.service.ISearchRpcService;
|
||||
import com.xspaceagi.log.sdk.vo.LogDocument;
|
||||
import com.xspaceagi.log.sdk.vo.SearchDocument;
|
||||
import com.xspaceagi.log.sdk.vo.SearchResult;
|
||||
import com.xspaceagi.system.sdk.common.TraceContext;
|
||||
import com.xspaceagi.system.sdk.service.AbstractTaskExecuteService;
|
||||
import com.xspaceagi.system.sdk.service.ScheduleTaskApiService;
|
||||
import com.xspaceagi.system.sdk.service.dto.ScheduleTaskDto;
|
||||
import com.xspaceagi.system.spec.utils.RedisUtil;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("logApplicationService")
|
||||
public class LogApplicationServiceImpl extends AbstractTaskExecuteService implements ILogRpcService {
|
||||
|
||||
@Resource
|
||||
private ScheduleTaskApiService scheduleTaskApiService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private ISearchRpcService iSearchRpcService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
scheduleTaskApiService.start(ScheduleTaskDto.builder()
|
||||
.taskId("logApplicationService")
|
||||
.beanId("logApplicationService")
|
||||
.maxExecTimes(Long.MAX_VALUE)
|
||||
.cron(ScheduleTaskDto.Cron.EVERY_2_SECOND.getCron())
|
||||
.params(Map.of())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(ScheduleTaskDto scheduleTaskDto) {
|
||||
try {
|
||||
checkAndPushLogDocument0();
|
||||
} catch (Exception e) {
|
||||
log.error("checkAndPushLogDocument0 error", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkAndPushLogDocument0() {
|
||||
List<LogDocument> logDocumentList = new ArrayList<>();
|
||||
Object val = redisUtil.rightPop("log:queue");
|
||||
while (val != null) {
|
||||
LogDocument logDocument = JSON.parseObject(val.toString(), LogDocument.class);
|
||||
if (logDocument != null) {
|
||||
logDocumentList.add(logDocument);
|
||||
}
|
||||
val = redisUtil.rightPop("log:queue");
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(logDocumentList)) {
|
||||
log.info("checkAndPushLogDocument0 logDocumentList size: {}", logDocumentList.size());
|
||||
iSearchRpcService.bulkIndex(logDocumentList.stream().map(logDocument -> (SearchDocument) logDocument).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLogDocument(String id) {
|
||||
iSearchRpcService.deleteDocument(LogDocument.class, id);
|
||||
}
|
||||
|
||||
public void bulkIndex(List<LogDocument> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
list.forEach(item -> redisUtil.rightPush("log:queue", JSON.toJSONString(item)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushTraceLog(Object traceContext0) {
|
||||
if (traceContext0 == null) {
|
||||
return;
|
||||
}
|
||||
redisUtil.rightPush("log:queue", JSON.toJSONString(((TraceContext) traceContext0).getLog()));
|
||||
((TraceContext) traceContext0).setLog(null);
|
||||
redisUtil.rightPush("bill:queue", JSON.toJSONString(traceContext0));
|
||||
}
|
||||
|
||||
public SearchResult search(DocumentSearchRequest documentSearchRequest) {
|
||||
return iSearchRpcService.search(documentSearchRequest);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.xspaceagi.log.app.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.xspaceagi.domain.model.AgentLogModel;
|
||||
import com.xspaceagi.domain.model.valueobj.AgentLogEntry;
|
||||
import com.xspaceagi.domain.model.valueobj.AgentLogSearchParams;
|
||||
import com.xspaceagi.domain.service.ILogPlatformDomainService;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 日志平台应用服务
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LogPlatformApplicationService {
|
||||
|
||||
@Resource
|
||||
private ILogPlatformDomainService logPlatformDomainService;
|
||||
|
||||
/**
|
||||
* 搜索智能体日志
|
||||
*/
|
||||
public IPage<AgentLogModel> searchAgentLogs(AgentLogSearchParams searchParams,
|
||||
Long current,
|
||||
Long pageSize) {
|
||||
// 调用领域服务
|
||||
return logPlatformDomainService.searchAgentLogs(searchParams, current, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
public AgentLogModel queryOneAgentLog(AgentLogSearchParams searchParams) {
|
||||
return logPlatformDomainService.queryOneAgentLog(searchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增单个智能体日志
|
||||
*/
|
||||
public boolean addAgentLog(AgentLogEntry logEntry) {
|
||||
return logPlatformDomainService.addAgentLog(logEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增智能体日志
|
||||
*/
|
||||
public boolean batchAddAgentLogs(List<AgentLogEntry> logEntries) {
|
||||
return logPlatformDomainService.batchAddAgentLogs(logEntries);
|
||||
}
|
||||
|
||||
/**
|
||||
* 健康检查
|
||||
*/
|
||||
public boolean healthCheck() {
|
||||
return logPlatformDomainService.healthCheck();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user