Struct pueue_lib::state::State [−][src]
pub struct State {
pub settings: Settings,
pub tasks: BTreeMap<usize, Task>,
pub groups: BTreeMap<String, GroupStatus>,
// some fields omitted
}Expand description
This is the full representation of the current state of the Pueue daemon.
This includes
- The currently used settings.
- The full task list
- The current status of all tasks
- All known groups.
However, the State does NOT include:
- Information about child processes
- Handles to child processes
That information is saved in the daemon’s TaskHandler.
Most functions implemented on the state shouldn’t be used by third party software.
The daemon is constantly changing and persisting the state.
Any changes applied to a state and saved to disk, will most likely be overwritten
after a short time.
The daemon uses the state as a piece of shared memory between it’s threads. It’s wrapped in a MutexGuard, which allows us to guarantee sequential access to any crucial information, such as status changes and incoming commands by the client.
Fields
settings: SettingsThe current settings used by the daemon.
tasks: BTreeMap<usize, Task>All tasks currently managed by the daemon.
groups: BTreeMap<String, GroupStatus>All groups
Implementations
Create a new default state.
A small helper to change the status of a specific task.
Add a new group to the daemon.
This also check if the given group already exists.
Create a state.group entry and a settings.group entry, if it doesn’t.
Remove a group.
This also iterates through all tasks and sets any tasks’ group
to the default group if it matches the deleted group.
Set the group status (running/paused) for all groups including the default queue.
Get all ids of task with a specific state inside a specific group.
Get all ids of task inside a specific group.
This checks, whether some tasks match the expected filter criteria.
The first result is the list of task_ids that match these statuses.
The second result is the list of task_ids that don’t match these statuses.
By default, this checks all tasks in the current state. If a list of task_ids is provided as the third parameter, only those tasks will be checked.
Same as [tasks_in_statuses], but only checks for tasks of a specific group.
Check if a task can be deleted.
We have to check all dependant tasks, that haven’t finished yet.
This is necessary to prevent deletion of tasks which are specified as a dependency.
to_delete A list of task ids, which should also be deleted.
This allows to remove dependency tasks as well as their dependants.
A small helper for handling task failures.
Users can specify whether they want to pause the task’s group or the
whole daemon on a failed tasks. This function wraps that logic and decides if anything should be
paused depending on the current settings.
group should be the name of the failed task.
Do a full reset of the state. This doesn’t reset any processes!
A small convenience wrapper for saving the settings to a file.
Save the current current state in a file with a timestamp. At the same time remove old state logs from the log directory. This function is called, when large changes to the state are applied, e.g. clean/reset.
Restore the last state from a previous session.
The state is stored as json in the pueue_directory.
If the state cannot be deserialized, an empty default state will be used instead.
All groups with queued tasks will be automatically paused to prevent unwanted execution.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Stateimpl UnwindSafe for StateBlanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V