제어관리 외부커넥션 설정기능
This commit is contained in:
@@ -447,17 +447,28 @@ router.get(
|
||||
return res.status(400).json(externalConnections);
|
||||
}
|
||||
|
||||
// 외부 커넥션들에 대해 연결 테스트 수행 (병렬 처리)
|
||||
// 외부 커넥션들에 대해 연결 테스트 수행 (병렬 처리, 타임아웃 5초)
|
||||
const testedConnections = await Promise.all(
|
||||
(externalConnections.data || []).map(async (connection) => {
|
||||
try {
|
||||
const testResult =
|
||||
await ExternalDbConnectionService.testConnectionById(
|
||||
connection.id!
|
||||
);
|
||||
// 개별 연결 테스트에 5초 타임아웃 적용
|
||||
const testPromise = ExternalDbConnectionService.testConnectionById(
|
||||
connection.id!
|
||||
);
|
||||
const timeoutPromise = new Promise<any>((_, reject) => {
|
||||
setTimeout(() => reject(new Error("연결 테스트 타임아웃")), 5000);
|
||||
});
|
||||
|
||||
const testResult = await Promise.race([
|
||||
testPromise,
|
||||
timeoutPromise,
|
||||
]);
|
||||
return testResult.success ? connection : null;
|
||||
} catch (error) {
|
||||
console.warn(`커넥션 테스트 실패 (ID: ${connection.id}):`, error);
|
||||
console.warn(
|
||||
`커넥션 테스트 실패 (ID: ${connection.id}):`,
|
||||
error instanceof Error ? error.message : error
|
||||
);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -51,6 +51,45 @@ router.get(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* GET /api/multi-connection/connections/:connectionId/tables/batch
|
||||
* 특정 커넥션의 모든 테이블 정보 배치 조회 (컬럼 수 포함)
|
||||
*/
|
||||
router.get(
|
||||
"/connections/:connectionId/tables/batch",
|
||||
authenticateToken,
|
||||
async (req: AuthenticatedRequest, res: Response) => {
|
||||
try {
|
||||
const connectionId = parseInt(req.params.connectionId);
|
||||
|
||||
if (isNaN(connectionId)) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: "유효하지 않은 커넥션 ID입니다.",
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(`배치 테이블 정보 조회 요청: connectionId=${connectionId}`);
|
||||
|
||||
const tables =
|
||||
await multiConnectionService.getBatchTablesWithColumns(connectionId);
|
||||
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
data: tables,
|
||||
message: `커넥션 ${connectionId}의 테이블 정보를 배치 조회했습니다.`,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(`배치 테이블 정보 조회 실패: ${error}`);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: "배치 테이블 정보 조회 중 오류가 발생했습니다.",
|
||||
error: error instanceof Error ? error.message : "알 수 없는 오류",
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* GET /api/multi-connection/connections/:connectionId/tables/:tableName/columns
|
||||
* 특정 커넥션의 테이블 컬럼 정보 조회 (메인 DB 포함)
|
||||
|
||||
Reference in New Issue
Block a user