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
use super::{ComputeOn, TaskDef, TaskDefOptions};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, time::Duration};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WasmOptions {
pub js_name: String,
pub wasm_name: String,
pub input_dir: String,
pub output_dir: String,
pub subtasks: HashMap<String, SubtaskDef>,
}
impl TaskDefOptions for WasmOptions {
const TASK_TYPE: &'static str = "WASM";
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SubtaskDef {
pub exec_args: Vec<String>,
pub output_file_paths: Vec<String>,
}
pub type WasmTaskDef = TaskDef<WasmOptions>;
pub fn template() -> WasmTaskDef {
let mut task_def = TaskDef {
task_type: WasmOptions::TASK_TYPE.to_string(),
compute_on: ComputeOn::CPU,
name: "simple wasm".to_string(),
timeout: Duration::from_secs(600),
subtask_timeout: Duration::from_secs(400),
subtasks_count: 1,
bid: 0.1,
resources: vec![],
concent_enabled: false,
options: WasmOptions {
js_name: "".to_string(),
wasm_name: "".to_string(),
input_dir: "".to_string(),
output_dir: "".to_string(),
subtasks: HashMap::new(),
},
};
task_def.options.subtasks.insert(
"subtask1".into(),
SubtaskDef {
exec_args: vec![],
output_file_paths: vec![],
},
);
task_def
}