MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / create_spec

Method create_spec

flow-rs/src/node/port.rs:90–136  ·  view source on GitHub ↗
(
        &mut self,
        key: u64,
        which: &str,
        resource: ResourceCollection,
        args: Table,
    )

Source from the content-addressed store, hash-verified

88 }
89
90 pub async fn create_spec(
91 &mut self,
92 key: u64,
93 which: &str,
94 resource: ResourceCollection,
95 args: Table,
96 ) -> Result<JoinHandle<Result<()>>> {
97 let broker = self
98 .brokers
99 .get(which)
100 .ok_or_else(|| anyhow!("{} not found", which))?;
101 if let Some(slice) = GraphSlice::registry_local()
102 .get(self.local_key)
103 .get(broker.topic())
104 {
105 let args = merge_table(self.args.clone(), args);
106 let mut g = (slice.cons)(format!("{}_instance", broker.topic()), &args)?;
107
108 let mut inputs = HashMap::new();
109 let mut outputs = HashMap::new();
110
111 for input in &slice.info.inputs {
112 let channel = ChannelStorage::bound(self.cap);
113 g.set_port(input.as_str(), None, &channel);
114 inputs.insert(input.clone(), channel.sender());
115 }
116
117 for output in &slice.info.outputs {
118 let channel = ChannelStorage::bound(self.cap);
119 g.set_port(output.as_str(), None, &channel);
120 outputs.insert(output.clone(), channel.receiver());
121 }
122
123 let handle = g.start(Some(resource));
124
125 broker
126 .publish(DynConns {
127 name: key,
128 inputs,
129 outputs,
130 })
131 .await;
132 Ok(handle)
133 } else {
134 Err(anyhow!("{} not found", broker.topic()))
135 }
136 }
137}
138
139impl DynPorts<Receiver> {

Callers 2

createMethod · 0.80
execMethod · 0.80

Calls 10

merge_tableFunction · 0.85
topicMethod · 0.80
insertMethod · 0.80
senderMethod · 0.80
receiverMethod · 0.80
publishMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45
set_portMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected