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
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scylla_models/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scylla_models"
version = "0.1.33"
version = "0.1.34-dev1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
14 changes: 10 additions & 4 deletions scylla_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct AddTaskModel {
pub queue: String,
}

#[derive(Debug)]
#[derive(Debug, Default)]
pub struct UpdateTaskModel {
pub rn: String,
pub operation: UpdateOperation,
Expand All @@ -21,6 +21,7 @@ pub struct UpdateTaskModel {
pub worker: Option<String>,
pub progress: Option<f32>,
pub task_timeout_in_secs: Option<i64>,
pub metrics: Option<Value>,
}

#[derive(Debug)]
Expand All @@ -41,11 +42,12 @@ impl Default for GetTaskModel {
}
}

#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub enum UpdateOperation {
Yield,
HeartBeat,
#[default]
Status,
Lease,
Reset,
Expand Down Expand Up @@ -129,6 +131,7 @@ pub struct Task {
pub owner: Option<String>,
pub errors: Vec<TaskError>,
pub history: Vec<TaskHistory>,
pub metrics: Option<Value>,
}
impl Default for Task {
fn default() -> Self {
Expand All @@ -145,6 +148,7 @@ impl Default for Task {
owner: None,
errors: Vec::default(),
history: Vec::default(),
metrics: None,
}
}
}
Expand Down Expand Up @@ -177,10 +181,11 @@ mod tests {
status: None,
worker: None,
task_timeout_in_secs: None,
metrics: None,
};
assert_eq!(
format!("{:?}", utm),
"UpdateTaskModel { rn: \"1.2.3\", operation: HeartBeat, status: None, error: None, worker: None, progress: None, task_timeout_in_secs: None }"
"UpdateTaskModel { rn: \"1.2.3\", operation: HeartBeat, status: None, error: None, worker: None, progress: None, task_timeout_in_secs: None, metrics: None }"
);
}
#[test]
Expand Down Expand Up @@ -268,7 +273,7 @@ mod tests {
..Task::default()
};
// debug trait
assert_eq!(format!("{:?}", t), format!("Task {{ rn: \"\", spec: Null, status: Ready, queue: \"\", progress: 0.0, priority: 0, created: {0:?}, updated: {0:?}, deadline: None, owner: None, errors: [], history: [] }}", t_now));
assert_eq!(format!("{:?}", t), format!("Task {{ rn: \"\", spec: Null, status: Ready, queue: \"\", progress: 0.0, priority: 0, created: {0:?}, updated: {0:?}, deadline: None, owner: None, errors: [], history: [], metrics: None }}", t_now));
// default()
let t = Task {
created: t_now,
Expand All @@ -290,6 +295,7 @@ mod tests {
owner: None,
errors: Vec::default(),
history: Vec::default(),
metrics: None,
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion scylla_operations/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scylla_operations"
version = "0.1.33"
version = "0.1.34-dev1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
9 changes: 2 additions & 7 deletions scylla_operations/src/task/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ fn update_task_calls_get_and_update() {
operation: UpdateOperation::Lease,
status: Some(TaskStatus::Running),
worker: Some("worker1".to_string()),
error: None,
progress: None,
task_timeout_in_secs: None,
..UpdateTaskModel::default()
};
let task_to_update = Task {
rn: "unique_id".to_string(),
Expand All @@ -58,10 +56,7 @@ fn update_task_returns_scylla_op_error() {
rn: "unique_id".to_string(),
operation: UpdateOperation::Status,
status: Some(TaskStatus::Completed),
worker: None,
error: None,
progress: None,
task_timeout_in_secs: None,
..UpdateTaskModel::default()
};

assert_eq!(
Expand Down
3 changes: 3 additions & 0 deletions scylla_operations/src/update_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub fn validate_status_operation(task: &Task, update_task_model: &UpdateTaskMode
fn prepare_status_task(mut task: Task, update_task_model: &UpdateTaskModel) -> Task {
task.status = update_task_model.status.clone().unwrap();
task.updated = Utc::now();
if let Some(metrics) = &update_task_model.metrics {
task.metrics = Some(metrics.clone());
}
if let Some(error) = update_task_model.error.clone() {
if task.status == TaskStatus::Aborted {
task.errors.push(error);
Expand Down
Loading
Loading