Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions api-model/src/buck2/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,75 @@ impl ProjectRelativePath {
opt.map(|s| Self(s.to_owned()))
}
}

/// Supported read modes for log APIs.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq, Eq, Default)]
#[serde(rename_all = "lowercase")]
pub enum LogReadMode {
#[default]
Full,
Segment,
}

/// Log stream event emitted by Orion worker/build processing.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LogEvent {
pub task_id: String,
pub repo_name: String,
pub build_id: String,
pub line: String,
pub is_end: bool,
}

/// Log segment read result.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LogSegment {
pub build_id: String,
pub offset: u64,
pub len: usize,
pub data: String,
pub next_offset: u64,
pub file_size: u64,
/// Whether we reached end of file
pub eof: bool,
}

/// Query parameters for target log APIs.
#[derive(Debug, Clone, Deserialize, ToSchema)]
pub struct TargetLogQuery {
#[serde(default)]
pub r#type: LogReadMode,
pub offset: Option<usize>,
pub limit: Option<usize>,
}

/// Query parameters for task history log APIs.
#[derive(Debug, Clone, Deserialize, ToSchema)]
pub struct TaskHistoryQuery {
pub task_id: String,
pub build_id: String,
pub repo: String,
pub start: Option<usize>,
pub end: Option<usize>,
}

/// Log lines response for history reads.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LogLinesResponse {
pub data: Vec<String>,
pub len: usize,
}

/// Log lines response for target reads.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct TargetLogLinesResponse {
pub data: Vec<String>,
pub len: usize,
pub build_id: String,
}

/// Error response for log-related APIs.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LogErrorResponse {
pub message: String,
}
1 change: 0 additions & 1 deletion api-model/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod buck2;
pub mod common;
pub mod git;
pub mod orion;
72 changes: 0 additions & 72 deletions api-model/src/orion/log.rs

This file was deleted.

1 change: 0 additions & 1 deletion api-model/src/orion/mod.rs

This file was deleted.

16 changes: 8 additions & 8 deletions orion-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use anyhow::Result;
use api_model::orion::log::{
use api_model::buck2::types::{
LogErrorResponse, LogEvent, LogLinesResponse, LogReadMode, TargetLogLinesResponse,
TargetLogQuery, TaskHistoryQuery,
};
Expand Down Expand Up @@ -263,10 +263,10 @@ pub async fn task_output_handler(
("end" = Option<usize>, Query, description = "End line number"),
),
responses(
(status = 200, description = "History Log", body = api_model::orion::log::LogLinesResponse),
(status = 400, description = "Invalid parameters", body = api_model::orion::log::LogErrorResponse),
(status = 404, description = "Log file not found", body = api_model::orion::log::LogErrorResponse),
(status = 500, description = "Failed to operate log file", body = api_model::orion::log::LogErrorResponse),
(status = 200, description = "History Log", body = api_model::buck2::types::LogLinesResponse),
(status = 400, description = "Invalid parameters", body = api_model::buck2::types::LogErrorResponse),
(status = 404, description = "Log file not found", body = api_model::buck2::types::LogErrorResponse),
(status = 500, description = "Failed to operate log file", body = api_model::buck2::types::LogErrorResponse),
)
)]
pub async fn task_history_output_handler(
Expand Down Expand Up @@ -323,10 +323,10 @@ pub async fn task_history_output_handler(
(
status = 200,
description = "Target log content",
body = api_model::orion::log::TargetLogLinesResponse
body = api_model::buck2::types::TargetLogLinesResponse
),
(status = 404, description = "Target or log not found", body = api_model::orion::log::LogErrorResponse),
(status = 500, description = "Failed to read log", body = api_model::orion::log::LogErrorResponse)
(status = 404, description = "Target or log not found", body = api_model::buck2::types::LogErrorResponse),
(status = 500, description = "Failed to read log", body = api_model::buck2::types::LogErrorResponse)
)
)]
pub async fn target_logs_handler(
Expand Down
2 changes: 1 addition & 1 deletion orion-server/src/log/log_service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{path::Path, sync::Arc};

use api_model::orion::log::LogEvent;
use api_model::buck2::types::LogEvent;
use futures::{Stream, StreamExt};
use tokio_stream::wrappers::BroadcastStream;

Expand Down
13 changes: 6 additions & 7 deletions orion-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ use crate::{
components(
schemas(
crate::scheduler::BuildRequest,
api_model::orion::log::LogSegment,
api_model::orion::log::LogLinesResponse,
api_model::orion::log::TargetLogLinesResponse,
api_model::orion::log::LogErrorResponse,
api_model::buck2::types::LogLinesResponse,
api_model::buck2::types::TargetLogLinesResponse,
api_model::buck2::types::LogErrorResponse,
api::TaskStatusEnum,
api::BuildDTO,
api::TargetDTO,
api_model::orion::log::TargetLogQuery,
api_model::orion::log::LogReadMode,
api_model::orion::log::TaskHistoryQuery,
api_model::buck2::types::TargetLogQuery,
api_model::buck2::types::LogReadMode,
api_model::buck2::types::TaskHistoryQuery,
api::TaskInfoDTO,
api::OrionClientInfo,
api::OrionClientStatus,
Expand Down
Loading