agent_tk/execution.rs
1//! This module handle the execution for the agent.
2
3use crate::{agent, delegation, module, states, utils, uuid};
4pub mod default;
5pub mod tst;
6
7// ___ _ __ __
8// |_ _|_ __ _ __ _ _| |_| \/ | ___ ___ ___ __ _ __ _ ___
9// | || '_ \| '_ \| | | | __| |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \
10// | || | | | |_) | |_| | |_| | | | __/\__ \__ \ (_| | (_| | __/
11// |___|_| |_| .__/ \__,_|\__|_| |_|\___||___/___/\__,_|\__, |\___|
12// |_| |___/
13
14/// Input message for the execution module
15#[derive(Clone)]
16pub enum InputMessage
17{
18 /// Queue the execution of the given task
19 QueueExecution
20 {
21 /// uuid of the task to execute
22 uuid: uuid::Uuid,
23 },
24 /// Cancel the execution of the given task
25 CancelExecution
26 {
27 /// uuid of the task to cancel
28 uuid: uuid::Uuid,
29 },
30}
31
32// ___ _ _ __ __
33// / _ \ _ _| |_ _ __ _ _| |_| \/ | ___ ___ ___ __ _ __ _ ___
34// | | | | | | | __| '_ \| | | | __| |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \
35// | |_| | |_| | |_| |_) | |_| | |_| | | | __/\__ \__ \ (_| | (_| | __/
36// \___/ \__,_|\__| .__/ \__,_|\__|_| |_|\___||___/___/\__,_|\__, |\___|
37// |_| |___/
38
39/// Output message for the execution module
40#[derive(Clone)]
41pub enum OutputMessage
42{
43 /// Current estimated state after the execution of the last task on the queue
44 CurrentEstimatedIdlingState
45 {
46 /// Current estimated cost of executing the entire queue
47 current_cost: f32,
48 /// The current estimated states, once the ecxecution
49 final_states: states::States,
50 /// Number of tasks on the queue
51 queue_length: usize,
52 },
53}
54
55// __ __ _ _ ___ _ __
56// | \/ | ___ __| |_ _| | ___|_ _|_ __ | |_ ___ _ __ / _| __ _ ___ ___
57// | |\/| |/ _ \ / _` | | | | |/ _ \| || '_ \| __/ _ \ '__| |_ / _` |/ __/ _ \
58// | | | | (_) | (_| | |_| | | __/| || | | | || __/ | | _| (_| | (_| __/
59// |_| |_|\___/ \__,_|\__,_|_|\___|___|_| |_|\__\___|_| |_| \__,_|\___\___|
60
61/// Module interface for the execution module
62pub type ModuleInterface = module::ModuleInterface<InputMessage, OutputMessage>;
63
64// __ __ _ _
65// | \/ | ___ __| |_ _| | ___
66// | |\/| |/ _ \ / _` | | | | |/ _ \
67// | | | | (_) | (_| | |_| | | __/
68// |_| |_|\___/ \__,_|\__,_|_|\___|
69
70/// Trait to define the interface to execution module
71pub trait Module:
72 module::Module<InputMessage = InputMessage, OutputMessage = OutputMessage> + Sized
73{
74 /// Creation options for the execution module
75 type Options;
76 /// Start an execution module
77 fn start(
78 agent_data: agent::AgentData,
79 module_interfaces: (
80 module::ModuleInterface<InputMessage, OutputMessage>,
81 Self::ModulePrivateInterface,
82 ),
83 options: Self::Options,
84 ) -> impl std::future::Future<Output = ()> + std::marker::Send + 'static;
85}