1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use flowcore::errors::Result;
#[cfg(feature = "metrics")]
use flowcore::model::metrics::Metrics;
use flowcore::model::submission::Submission;
use crate::run_state::RunState;
/// Programs that wish to submit a flow for execution via a
/// [Submission][flowcore::model::submission::Submission] and
/// then track it's execution (such as a CLI or a UI) should implement this trait
pub trait SubmissionHandler {
/// Execution of the flow is starting
///
/// # Errors
///
/// Returns an error if the message corresponding to the flow is starting cannot be sent
fn flow_execution_starting(&mut self) -> Result<()>;
/// The [Coordinator][crate::coordinator::Coordinator] executing the flow periodically
/// will check if there has been a request to enter the debugger.
///
/// # Errors
///
/// Returns an error if the request to check if debugger entry is required fails
#[cfg(feature = "debugger")]
fn should_enter_debugger(&mut self) -> Result<bool>;
/// The [Coordinator][crate::coordinator::Coordinator] informs the submitter that the execution
/// of the flow has ended
///
/// # Errors
///
/// Returns an error if the message corresponding to the flow has ended cannot be sent
fn flow_execution_ended(
&mut self,
state: &RunState,
#[cfg(feature = "metrics")] metrics: Metrics,
) -> Result<()>;
/// The [Coordinator][crate::coordinator::Coordinator] wait for a
/// [Submission][flowcore::model::submission::Submission] to be sent for execution
///
/// # Errors
///
/// Returns an error if there is an error while waiting for a submission (usually networking9
///
fn wait_for_submission(&mut self) -> Result<Option<Submission>>;
/// The [Coordinator][crate::coordinator::Coordinator] periodically checks if the client
/// has requested that execution be stopped.
///
/// # Errors
///
/// Returns an error if the check fails
fn should_stop(&mut self) -> Result<bool> {
Ok(false)
}
/// Called by the [Coordinator][crate::coordinator::Coordinator] after jobs are retired,
/// with the total number of jobs created so far. Default implementation is a no-op.
fn jobs_created(&mut self, _count: usize) {}
/// The [Coordinator][crate::coordinator::Coordinator] is about to exit
///
/// # Errors
///
/// Will return `Err` if this cannot be communicated to the client
fn coordinator_is_exiting(&mut self, result: Result<()>) -> Result<()>;
}