diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-02-08 10:13:12 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-02-08 10:54:54 +0100 |
commit | 2f53c7acf4ad5bd9830d3b122231ed06841811c3 (patch) | |
tree | 99a43fd95fbd13713eb22241532fb0fcfa313114 /src/orchestrator/orchestrator.rs | |
parent | c0caf996654768d736fc6a13c24942efdaeba38e (diff) |
Outsource JobTask construction to constructor function
This patch outsources the construction of a JobTask object to a constructor
function.
This fixes a inconvenience, where the progress bar was not updated until the
JobTask began run()ing.
Now we set a message for the progress bar in the constructor, making the user
experience a bit nicer.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/orchestrator/orchestrator.rs')
-rw-r--r-- | src/orchestrator/orchestrator.rs | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs index f5dd8cb..889707a 100644 --- a/src/orchestrator/orchestrator.rs +++ b/src/orchestrator/orchestrator.rs @@ -311,23 +311,9 @@ impl<'a> Orchestrator<'a> { .into_iter() .map(|prep| { trace!("Creating JobTask for = {}", prep.1.jobdef.job.uuid()); - let root_sender = root_sender.clone(); - JobTask { - jobdef: prep.1.jobdef, - - bar: prep.1.bar.clone(), - - config: prep.1.config, - source_cache: prep.1.source_cache, - scheduler: prep.1.scheduler, - merged_stores: prep.1.merged_stores, - database: prep.1.database.clone(), - - receiver: prep.0, - - // the sender is set or we need to use the root sender - sender: prep.3.into_inner().unwrap_or_else(|| vec![root_sender]), - } + // the sender is set or we need to use the root sender + let sender = prep.3.into_inner().unwrap_or_else(|| vec![root_sender.clone()]); + JobTask::new(prep.0, prep.1, sender) }) .map(|task| task.run()) .collect::<futures::stream::FuturesUnordered<_>>(); @@ -387,6 +373,28 @@ struct JobTask<'a> { } impl<'a> JobTask<'a> { + fn new(receiver: Receiver<JobResult>, prep: TaskPreparation<'a>, sender: Vec<Sender<JobResult>>) -> Self { + let bar = prep.bar.clone(); + bar.set_message(&format!("[{} {} {}]: Booting", + prep.jobdef.job.uuid(), + prep.jobdef.job.package().name(), + prep.jobdef.job.package().version() + )); + JobTask { + jobdef: prep.jobdef, + + bar, + + config: prep.config, + source_cache: prep.source_cache, + scheduler: prep.scheduler, + merged_stores: prep.merged_stores, + database: prep.database.clone(), + + receiver, + sender, + } + } /// Run the job /// |