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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Execution Engine MkII
//!
//! ---
//!
//! The EE is split into 2 main parts
//! 1. [Executor](crate::executor) - This is responsible for driving the workflows to completion and should contain
//! all the objects required for each workflow to be executed, think of this as a runtime.
//! 2. [Reactor](crate::reactor) - The reactor is responsible for notifying the executor when a future can make
//! progress, this is done via the Waker API.
//!
//! When a workflow is sent to the EE, the flow is as follows:
//! 1. Spawn a new task which will perform all of the work associated with executing a wf to
//! completion
//! 2. Deserialize the workflow into a Job, the Job type should describe the entity as accurately
//! as possible
//! 3. Drive the workflow forward, this uses an event based stream to do so
//!
//! When a workflow reaches a point where it cannot make progress (e.g. waiting for Bots to Lock or
//! waiting for an Activity to complete) it should yield execution using the underlying mechanics
//! of Rust's async/await.
//!
//!
pub use io;
pub use task;
use crate;
/// Sets up the runtime and starts the message broker listeners
///
/// The `start` function creates the structures used by the Runtime and starts the Reactor, Spawner and MsgBroker consumers.
///
/// 1. The [Reactor](crate::reactor) - This includes the channel to send messages to the reactor and
/// the Reactor struct itself. The Reactor is then run in a separate task and we `await` on the task's `Handle`.
/// 2. The [Spawner](crate::spawner) - First, a channel to communicate to the Spawner is created, then
/// a new Spawner struct is created, passing in the `Receiver` for the channel. The Spawner is run in
/// a background task and we `await` on the task's `Handle`.
/// 3. The [NATs](https://docs.nats.io/) consumer - This creates a NATs consumer listening for messages
/// on the `jobs.execute` and `jobs.cancel` topics.
pub async