Skip to content

Commit 5a2b8d6

Browse files
authored
feat: Add local testing API and enhance orion/orion-server with heartbeat and task scheduling (#1306)
1.Added a new API in mono to enable local testing without login requirement 2.Implemented heartbeat mechanism in orion-server and orion for persistent connection and reconnection 3.Added task scheduling and status checking features in orion-server and orion
1 parent eb18920 commit 5a2b8d6

File tree

12 files changed

+906
-488
lines changed

12 files changed

+906
-488
lines changed

mono/src/api/mr/mr_router.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn routers() -> OpenApiRouter<MonoApiServiceState> {
3434
.routes(routes!(fetch_mr_list))
3535
.routes(routes!(mr_detail))
3636
.routes(routes!(merge))
37+
.routes(routes!(merge_no_auth))
3738
.routes(routes!(close_mr))
3839
.routes(routes!(reopen_mr))
3940
.routes(routes!(mr_files_changed))
@@ -170,6 +171,42 @@ async fn merge(
170171
Ok(Json(CommonResult::success(None)))
171172
}
172173

174+
/// Merge Request without authentication
175+
/// It's for local testing purposes.
176+
#[utoipa::path(
177+
post,
178+
params(
179+
("link", description = "MR link"),
180+
),
181+
path = "/{link}/merge-no-auth",
182+
responses(
183+
(status = 200, body = CommonResult<String>, content_type = "application/json")
184+
),
185+
tag = MR_TAG
186+
)]
187+
async fn merge_no_auth(
188+
Path(link): Path<String>,
189+
state: State<MonoApiServiceState>,
190+
) -> Result<Json<CommonResult<String>>, ApiError> {
191+
let res = state.mr_stg().get_mr(&link).await?;
192+
let model = res.ok_or(MegaError::with_message("MR Not Found"))?;
193+
194+
if model.status != MergeStatusEnum::Open {
195+
return Err(ApiError::from(MegaError::with_message(format!(
196+
"MR is not in Open status, current status: {:?}",
197+
model.status
198+
))));
199+
}
200+
201+
// No authentication required - using default system user
202+
let default_username = "system";
203+
state.monorepo().merge_mr(default_username, model).await?;
204+
205+
Ok(Json(CommonResult::success(Some(
206+
"Merge completed successfully".to_string(),
207+
))))
208+
}
209+
173210
/// Fetch MR list
174211
#[utoipa::path(
175212
post,

orion-server/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD_LOG_DIR="/tmp/buck2ctl"
1+
BUILD_LOG_DIR="/tmp/megadir/buck2ctl"
22
DATABASE_URL="postgres://postgres:postgres@localhost/orion"
3-
PORT=8004
3+
PORT=80

orion-server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ dashmap = { workspace = true }
2929
utoipa-axum.workspace = true
3030
utoipa.workspace = true
3131
utoipa-swagger-ui = { workspace = true, features = ["axum"] }
32+
chrono = { version = "0.4", features = ["serde"] }

0 commit comments

Comments
 (0)