Skip to content

Commit

Permalink
refactor: remove innecessary serde (databendlabs#15042)
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer authored Mar 20, 2024
1 parent 31a63b1 commit 89cdf6b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 43 deletions.
52 changes: 17 additions & 35 deletions src/meta/app/src/background/background_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ use cron::Schedule;
use crate::background::BackgroundTaskType;
use crate::principal::UserIdentity;

#[derive(
serde::Serialize,
serde::Deserialize,
Clone,
Debug,
Default,
Eq,
PartialEq,
num_derive::FromPrimitive,
)]
#[derive(Clone, Debug, Default, Eq, PartialEq, num_derive::FromPrimitive)]
pub enum BackgroundJobState {
#[default]
RUNNING = 0,
Expand All @@ -47,16 +38,7 @@ impl Display for BackgroundJobState {
}
}

#[derive(
serde::Serialize,
serde::Deserialize,
Clone,
Debug,
Default,
Eq,
PartialEq,
num_derive::FromPrimitive,
)]
#[derive(Clone, Debug, Default, Eq, PartialEq, num_derive::FromPrimitive)]
pub enum BackgroundJobType {
#[default]
ONESHOT = 0,
Expand Down Expand Up @@ -87,7 +69,7 @@ impl ManualTriggerParams {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BackgroundJobParams {
pub job_type: BackgroundJobType,
pub scheduled_job_interval: std::time::Duration,
Expand Down Expand Up @@ -159,7 +141,7 @@ impl Display for BackgroundJobParams {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BackgroundJobStatus {
pub job_state: BackgroundJobState,
pub last_task_id: Option<String>,
Expand Down Expand Up @@ -216,7 +198,7 @@ impl Display for BackgroundJobIdent {
}

// Info
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BackgroundJobInfo {
pub job_params: Option<BackgroundJobParams>,
pub job_status: Option<BackgroundJobStatus>,
Expand Down Expand Up @@ -244,12 +226,12 @@ impl BackgroundJobInfo {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BackgroundJobId {
pub id: u64,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CreateBackgroundJobReq {
pub if_not_exists: bool,
pub job_name: BackgroundJobIdent,
Expand All @@ -271,12 +253,12 @@ impl Display for CreateBackgroundJobReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CreateBackgroundJobReply {
pub id: u64,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetBackgroundJobReq {
pub name: BackgroundJobIdent,
}
Expand All @@ -287,13 +269,13 @@ impl Display for GetBackgroundJobReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetBackgroundJobReply {
pub id: u64,
pub info: BackgroundJobInfo,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundJobStatusReq {
pub job_name: BackgroundJobIdent,
pub status: BackgroundJobStatus,
Expand All @@ -309,7 +291,7 @@ impl Display for UpdateBackgroundJobStatusReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundJobParamsReq {
pub job_name: BackgroundJobIdent,
pub params: BackgroundJobParams,
Expand All @@ -325,7 +307,7 @@ impl Display for UpdateBackgroundJobParamsReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundJobReq {
pub job_name: BackgroundJobIdent,
pub info: BackgroundJobInfo,
Expand All @@ -347,12 +329,12 @@ impl Display for UpdateBackgroundJobReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundJobReply {
pub id: u64,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DeleteBackgroundJobReq {
pub name: BackgroundJobIdent,
}
Expand All @@ -363,10 +345,10 @@ impl Display for DeleteBackgroundJobReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DeleteBackgroundJobReply {}
// list
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListBackgroundJobsReq {
pub tenant: String,
}
Expand Down
12 changes: 6 additions & 6 deletions src/meta/app/src/background/background_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Display for BackgroundTaskType {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct BackgroundTaskIdent {
pub tenant: String,
pub task_id: String,
Expand Down Expand Up @@ -153,7 +153,7 @@ impl BackgroundTaskInfo {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundTaskReq {
pub task_name: BackgroundTaskIdent,
pub task_info: BackgroundTaskInfo,
Expand All @@ -174,13 +174,13 @@ impl Display for UpdateBackgroundTaskReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UpdateBackgroundTaskReply {
pub last_updated: DateTime<Utc>,
pub expire_at: u64,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetBackgroundTaskReq {
pub name: BackgroundTaskIdent,
}
Expand All @@ -191,12 +191,12 @@ impl Display for GetBackgroundTaskReq {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct GetBackgroundTaskReply {
pub task_info: Option<BackgroundTaskInfo>,
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListBackgroundTasksReq {
pub tenant: String,
}
Expand Down
4 changes: 2 additions & 2 deletions src/query/config/src/background_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ impl BackgroundScheduledConfig {
}

/// Config for background config
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq)]
pub struct InnerBackgroundConfig {
pub enable: bool,
pub compaction: InnerBackgroundCompactionConfig,
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq)]
pub struct InnerBackgroundCompactionConfig {
pub enable: bool,
pub target_tables: Option<Vec<String>>,
Expand Down

0 comments on commit 89cdf6b

Please sign in to comment.