|
| 1 | +use std::path::PathBuf; |
| 2 | + |
| 3 | +// FIXME: look at EC2 etc, to have a better list of required fields |
| 4 | +#[derive(Debug)] |
| 5 | +struct EnvResource { |
| 6 | + num_cpu: u32, |
| 7 | + num_ram: u64, |
| 8 | +} |
| 9 | + |
| 10 | +/// Config for how to launch the VRE, these are specifically for e.g. `.binder`. |
| 11 | +/// The resource description is independent of this config. |
| 12 | +/// The request packager do not (should not??, but if tool-registry also strong typed, maybe I can |
| 13 | +/// constructed the type easily here??) know the exact format of the config. The format is |
| 14 | +/// encoded in the tool-registry and know b |
| 15 | +/// TODO: if the overall architecture and tech stack can not change (ask Enol whether he want to |
| 16 | +/// uptake the grpc in more broad scope in dispacher and tool-registry). Otherwise, check if |
| 17 | +/// RO-crate can provide such level of schema check. |
| 18 | +#[derive(Debug)] |
| 19 | +struct Config { |
| 20 | + inner: serde_json::Value, |
| 21 | +} |
| 22 | + |
| 23 | +#[derive(Debug)] |
| 24 | +enum VirtualResearchEnv { |
| 25 | + // tool that opened inline in the page. |
| 26 | + EoscInline { |
| 27 | + tool_id: String, |
| 28 | + file: PathBuf, |
| 29 | + }, |
| 30 | + |
| 31 | + // tool that redirect to 3rd-party site with the selected files |
| 32 | + // such tools are very lightweight and do not need to specify resources. |
| 33 | + BrowserNative { |
| 34 | + tool_id: String, |
| 35 | + files: Vec<PathBuf>, |
| 36 | + }, |
| 37 | + |
| 38 | + // tool that need VM resources and have resources attached (e.g. RRP, Galaxy) |
| 39 | + Hosted { |
| 40 | + tool_id: String, |
| 41 | + config: Option<Config>, |
| 42 | + files: Vec<PathBuf>, |
| 43 | + }, |
| 44 | + |
| 45 | + // (planned): |
| 46 | + // Hosted but allow to allocating using EOSC resources. |
| 47 | + HostedWithBuiltInRes { |
| 48 | + tool_id: String, |
| 49 | + config: Option<Config>, |
| 50 | + files: Vec<PathBuf>, |
| 51 | + res: EnvResource, |
| 52 | + }, |
| 53 | + |
| 54 | + // (planned): |
| 55 | + // Hosted but allow to asking for tools that provide resourecs. |
| 56 | + HostedWithPluginRes { |
| 57 | + tool_id: String, |
| 58 | + config: Option<Config>, |
| 59 | + res_id: String, |
| 60 | + files: Vec<PathBuf>, |
| 61 | + res: EnvResource, |
| 62 | + }, |
| 63 | +} |
| 64 | + |
| 65 | +// TODO: have a protobuf defined for the VirtualResearchEnv and mapping conversion here |
| 66 | +// |
| 67 | +// impl From<proto::VirtualResearchEnv> for VirtualResearchEnv { |
| 68 | +// fn from(value: proto::VirtualResearchEnv) -> Self { |
| 69 | +// match value { |
| 70 | +// => |
| 71 | +// => |
| 72 | +// => |
| 73 | +// => |
| 74 | +// } |
| 75 | +// } |
| 76 | +// } |
| 77 | + |
| 78 | +// server side call this function to assemble a payload that can send to downstream dispacher |
| 79 | +// XXX: the return type is a very generic json, I probably want a crate to handle ro-crate |
| 80 | +// specificly. |
| 81 | +fn assemble_vre_request(vre: &VirtualResearchEnv) -> serde_json::Value { |
| 82 | + match vre { |
| 83 | + VirtualResearchEnv::EoscInline { tool_id, file } => todo!(), |
| 84 | + VirtualResearchEnv::BrowserNative { tool_id, files } => todo!(), |
| 85 | + VirtualResearchEnv::Hosted { tool_id, config, files } => todo!(), |
| 86 | + VirtualResearchEnv::HostedWithBuiltInRes { tool_id, config, files, res } => todo!(), |
| 87 | + VirtualResearchEnv::HostedWithPluginRes { tool_id, config, res_id, files, res } => todo!(), |
| 88 | + } |
| 89 | +} |
0 commit comments