mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-04 11:46:30 +00:00
Add network
to Task
and TaskView
This commit is contained in:
@ -11,6 +11,7 @@ use crate::error::ResponseError;
|
|||||||
use crate::settings::{Settings, Unchecked};
|
use crate::settings::{Settings, Unchecked};
|
||||||
use crate::tasks::{
|
use crate::tasks::{
|
||||||
serialize_duration, Details, DetailsExportIndexSettings, IndexSwap, Kind, Status, Task, TaskId,
|
serialize_duration, Details, DetailsExportIndexSettings, IndexSwap, Kind, Status, Task, TaskId,
|
||||||
|
TaskNetwork,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, ToSchema)]
|
#[derive(Debug, Clone, PartialEq, Serialize, ToSchema)]
|
||||||
@ -51,6 +52,9 @@ pub struct TaskView {
|
|||||||
#[schema(value_type = String, example = json!("2024-08-08_14:12:09.393Z"))]
|
#[schema(value_type = String, example = json!("2024-08-08_14:12:09.393Z"))]
|
||||||
#[serde(with = "time::serde::rfc3339::option", default)]
|
#[serde(with = "time::serde::rfc3339::option", default)]
|
||||||
pub finished_at: Option<OffsetDateTime>,
|
pub finished_at: Option<OffsetDateTime>,
|
||||||
|
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub network: Option<TaskNetwork>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TaskView {
|
impl TaskView {
|
||||||
@ -68,6 +72,7 @@ impl TaskView {
|
|||||||
enqueued_at: task.enqueued_at,
|
enqueued_at: task.enqueued_at,
|
||||||
started_at: task.started_at,
|
started_at: task.started_at,
|
||||||
finished_at: task.finished_at,
|
finished_at: task.finished_at,
|
||||||
|
network: task.network.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@ pub struct Task {
|
|||||||
|
|
||||||
pub status: Status,
|
pub status: Status,
|
||||||
pub kind: KindWithContent,
|
pub kind: KindWithContent,
|
||||||
|
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub network: Option<TaskNetwork>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Task {
|
impl Task {
|
||||||
@ -737,6 +740,35 @@ pub enum Details {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, ToSchema)]
|
||||||
|
#[serde(untagged, rename_all = "camelCase")]
|
||||||
|
pub enum TaskNetwork {
|
||||||
|
Origin { origin: Origin },
|
||||||
|
Remotes { remote_tasks: BTreeMap<String, RemoteTask> },
|
||||||
|
}
|
||||||
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, ToSchema)]
|
||||||
|
pub struct Origin {
|
||||||
|
pub remote_name: String,
|
||||||
|
pub task_uid: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, ToSchema)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct RemoteTask {
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
task_uid: Option<TaskId>,
|
||||||
|
error: Option<ResponseError>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Result<TaskId, ResponseError>> for RemoteTask {
|
||||||
|
fn from(res: Result<TaskId, ResponseError>) -> RemoteTask {
|
||||||
|
match res {
|
||||||
|
Ok(task_uid) => RemoteTask { task_uid: Some(task_uid), error: None },
|
||||||
|
Err(err) => RemoteTask { task_uid: None, error: Some(err) },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, ToSchema)]
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, ToSchema)]
|
||||||
#[schema(rename_all = "camelCase")]
|
#[schema(rename_all = "camelCase")]
|
||||||
pub struct DetailsExportIndexSettings {
|
pub struct DetailsExportIndexSettings {
|
||||||
|
Reference in New Issue
Block a user