| 57 | } |
| 58 | |
| 59 | pub(crate) fn load_static( |
| 60 | local_key: u64, |
| 61 | config: &crate::config::interlayer::Node, |
| 62 | ) -> Result<Vec<Box<dyn Actor>>> { |
| 63 | if config.entity.ty.len() > 1 { |
| 64 | return Err(anyhow!("static subgraph/node dont support dyn type")); |
| 65 | } |
| 66 | let ty = config.entity.ty.first().unwrap(); |
| 67 | if let Some(node) = NodeSlice::registry_local().get(local_key).get(ty) { |
| 68 | Ok((0..config.cloned.unwrap_or(1)) |
| 69 | .into_iter() |
| 70 | .map(|_| (node.cons)(config.entity.name.clone(), &config.entity.args)) |
| 71 | .collect()) |
| 72 | } else if let Some(graph) = GraphSlice::registry_local().get(local_key).get(ty) { |
| 73 | (0..config.cloned.unwrap_or(1)) |
| 74 | .into_iter() |
| 75 | .map(|_| (graph.cons)(config.entity.name.clone(), &config.entity.args)) |
| 76 | .map(|g| g.map(|g| Box::new(g) as Box<dyn Actor>)) |
| 77 | .collect() |
| 78 | } else { |
| 79 | Err(anyhow!( |
| 80 | "unexpected node {}:{:?}", |
| 81 | config.entity.name, |
| 82 | config.entity.ty |
| 83 | )) |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | pub(crate) fn inputs(local_key: u64, ty: &str) -> Result<BTreeSet<String>> { |
| 88 | if let Some(node) = NodeSlice::registry_local().get(local_key).get(ty) { |