pub struct Runtime {
    pub ctx: Ctx,
    pub jobs: Vec<Job>,
}
Expand description

Represents and contains a given runtime.

This object contains an ordered list of jobs, each job containing an ordered list of tasks, each task containing one or more concurrent processes. This object also contains a ctx object which contains the binary command and args for the current runtime as well as hashmap indexes for processes and log monitors which are copied to each child job, task, and process so that the runtime can instantiate new processes and log monitors on the fly.

A visual representation:

    Runtime
T       |
I       > [ Job1, Job2, ... ]
M             |
E             > [ Task1, Task2, ... ]
                    |
|                   > Process1 -> `echo foo`
|                   |     |
|                   |     > OnSucceed: Process2 -> `echo bar`
v                   |
                    > Process2 -> `echo bar`

    ...

    Runtime
        |
        > [ Job1, Job2, ... ]
              |
              > [ Task1, Task2, ... ]
                           |
                           > Process3 -> `echo baz`

    ...

    Runtime
        |
        > [ Job1, Job2, ... ]
                    |
                    > [ Task1, ... ]
                          |
                          > Process4 -> `echo qux`

Processes in a given task run concurrently.

Once all processes in the task have exited, including actions (onsucceed, onfail, and log monitor ontrigger actions spawned on their parent process threads), the task is complete and the next task in the job will execute.

Once all tasks in a given job have completed their execution, the runtime moves on to the next job in the queue. Once all jobs have completed their execution, the runtime is finished.

Examples:

Basic usage:

use arpx::{Job, Process, Runtime, Task};
use std::collections::HashMap;

let processes = vec![
    Process::new("p_foo".to_string())
        .command("echo foo".to_string())
        .onsucceed(Some("p_baz".to_string())),
    Process::new("p_bar".to_string()).command("echo bar".to_string()),
];

let mut process_map = processes
    .clone()
    .into_iter()
    .map(|process| (process.name.clone(), process))
    .collect::<HashMap<String, Process>>();

process_map.insert(
    "p_baz".to_string(),
    Process::new("p_baz".to_string()).command("echo baz".to_string()),
);

let jobs = vec![Job::new(
    "my_job".to_string(),
    vec![Task::new(processes)],
)];

Runtime::new()
    .jobs(jobs)
    .process_map(process_map)
    .run();

// Output:
//
// [p_foo] "p_foo" (1) spawned
// [p_bar] "p_bar" (2) spawned
// [p_foo] foo
// [p_bar] bar
// [p_foo] "p_foo" (1) succeeded
// [p_bar] "p_bar" (2) succeeded
// [p_foo] "p_baz" (3) spawned
// [p_foo] baz
// [p_foo] "p_baz" (3) succeeded

Note that p_baz runs on the p_foo thread, since p_foo executes it onsucceed.

Fields

ctx: Ctxjobs: Vec<Job>

Implementations

Constructs a new, empty Runtime.

Builds Runtime with the specified jobs.

Builds Runtime with the specified log monitors.

Builds Runtime with the specified processes.

Builds Runtime with the specified binary command.

Constructs a new Runtime from a profile at the specified path, using the specified jobs.

Executes the runtime.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.