Skip to content
Draft
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
286 changes: 235 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions components/spider-core/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ impl JobState {
matches!(self, Self::Succeeded | Self::Failed | Self::Cancelled)
}

/// # Returns
///
/// Whether the job is in [`JobState::Running`] state.
#[must_use]
pub const fn is_running(&self) -> bool {
matches!(self, Self::Running)
}

/// # Returns
///
/// Whether the state transition `from` -> `to` is valid.
Expand Down
30 changes: 29 additions & 1 deletion components/spider-core/src/task.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod task_graph;
mod type_descriptor;

use serde::{Deserialize, Serialize};
pub use task_graph::*;
use thiserror::Error;
pub use type_descriptor::*;
Expand All @@ -24,14 +25,41 @@ pub enum Error {
}

/// Enum for all possible states of a task.
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum TaskState {
PENDING,
Pending,
Ready,
Running,
Succeeded,
Failed(String),
Cancelled,
}

impl TaskState {
#[must_use]
pub const fn is_terminal(&self) -> bool {
matches!(self, Self::Succeeded | Self::Failed(_) | Self::Cancelled)
}
}

/// Represents metadata associated with a task.
pub struct TaskMetadata {}

/// Execution policy for a task, controlling concurrency and retry behavior.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExecutionPolicy {
/// The maximum number of concurrent instances allowed for this task.
pub max_num_instances: usize,

/// The maximum number of retries allowed for this task on failure.
pub max_num_retries: usize,
}

impl Default for ExecutionPolicy {
fn default() -> Self {
Self {
max_num_instances: 1,
max_num_retries: 0,
}
}
}
Loading
Loading