pub struct TaskSpec {
pub config: TaskConfig,
pub shell: Option<TaskShell>,
pub dependencies: Option<Vec<String>>,
pub terminate_after_dependents_finished: Option<bool>,
pub ignore_dependencies_error: Option<bool>,
}
Expand description
Task specification with dependency management and execution configuration.
Wraps a TaskConfig
with additional metadata for dependency management,
shell selection, and execution behavior in a task graph.
§Default Values
config
: Default-initializedTaskConfig
shell
:Some(TaskShell::None)
dependencies
:None
terminate_after_dependents_finished
:Some(false)
ignore_dependencies_error
:Some(false)
§Examples
§Simple Task
use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;
let task = TaskSpec::new(
TaskConfig::new("echo").args(["Hello, World!"])
);
§Task with Dependencies
use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;
let build_task = TaskSpec::new(
TaskConfig::new("cargo").args(["build", "--release"])
)
.dependencies(["test", "lint"])
.shell(TaskShell::Auto)
.terminate_after_dependents(true);
§Task with Custom Configuration
use tcrm_monitor::monitor::config::{TaskSpec, TaskShell};
use tcrm_task::tasks::config::TaskConfig;
let server_task = TaskSpec::new(
TaskConfig::new("node")
.args(["server.js"])
.working_dir("/app")
.enable_stdin(true)
.timeout_ms(0) // No timeout
)
.shell(TaskShell::Auto)
.ignore_dependencies_error(true);
Fields§
§config: TaskConfig
The underlying task configuration containing command, arguments, and execution options.
Default: TaskConfig::default()
shell: Option<TaskShell>
Shell to use for task execution. None
means direct execution without shell.
Default: Some(TaskShell::None)
dependencies: Option<Vec<String>>
List of task names this task depends on. Must complete before this task starts.
Default: None
terminate_after_dependents_finished: Option<bool>
Whether to terminate this task when all dependent tasks finish. Useful for long-running services that should stop when their dependents complete.
Default: Some(false)
ignore_dependencies_error: Option<bool>
Whether to ignore errors from dependency tasks and continue execution anyway.
Default: Some(false)
Implementations§
Source§impl TaskSpec
impl TaskSpec
Sourcepub fn new(config: TaskConfig) -> Self
pub fn new(config: TaskConfig) -> Self
Sourcepub fn dependencies<I, S>(self, dependencies: I) -> Self
pub fn dependencies<I, S>(self, dependencies: I) -> Self
Adds dependencies to this task.
Dependencies must complete successfully before this task can start.
§Arguments
dependencies
- An iterator of task names this task depends on
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;
let task = TaskSpec::new(TaskConfig::new("cargo").args(["build"]))
.dependencies(["test", "lint"]);
Sourcepub fn terminate_after_dependents(self, terminate: bool) -> Self
pub fn terminate_after_dependents(self, terminate: bool) -> Self
Sets whether to terminate this task when its dependents complete.
Useful for long-running services that should stop when their dependents finish.
§Arguments
terminate
- Whether to terminate after dependents complete
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;
// A database server that should stop when tests finish
let db_task = TaskSpec::new(TaskConfig::new("postgres").args(["-D", "/data"]))
.terminate_after_dependents(true);
Sourcepub fn ignore_dependencies_error(self, ignore: bool) -> Self
pub fn ignore_dependencies_error(self, ignore: bool) -> Self
Sets whether to ignore errors from dependency tasks.
When true, this task will run even if its dependencies fail.
§Arguments
ignore
- Whether to ignore dependency errors
§Examples
use tcrm_monitor::monitor::config::TaskSpec;
use tcrm_task::tasks::config::TaskConfig;
// Cleanup task that should run regardless of test results
let cleanup = TaskSpec::new(TaskConfig::new("rm").args(["-rf", "/tmp/test"]))
.dependencies(["test"])
.ignore_dependencies_error(true);