MCPcopy Create free account
hub / github.com/Botloader/botloader / dispatch

Method dispatch

components/scheduler/src/vm_session.rs:161–195  ·  view source on GitHub ↗

Sends an event to the vm, recording a pending ack for it. On send failure the worker is broken and the ack payload is handed back so the caller can retry on a new session.

(
        &mut self,
        name: String,
        data: serde_json::Value,
        ack: PendingAckType,
        source: EventSource,
        ts: DateTime<Utc>,
    )

Source from the content-addressed store, hash-verified

159 /// On send failure the worker is broken and the ack payload is handed back
160 /// so the caller can retry on a new session.
161 pub fn dispatch(
162 &mut self,
163 name: String,
164 data: serde_json::Value,
165 ack: PendingAckType,
166 source: EventSource,
167 ts: DateTime<Utc>,
168 ) -> Result<(), PendingAckType> {
169 let evt_id = self.gen_dispatch_id();
170
171 match self.worker.tx.send(SchedulerMessage::Dispatch(VmDispatchEvent {
172 name,
173 seq: evt_id,
174 value: data,
175 source,
176 source_timestamp: ts,
177 })) {
178 Ok(()) => {
179 self.pending_acks.insert(
180 evt_id,
181 PendingAck {
182 dispatched_session_id: self.vm_session_id,
183 kind: ack,
184 dispatched: Some(DispatchMeta {
185 source,
186 source_timestamp: ts,
187 vm_cold: self.vm_cold,
188 }),
189 },
190 );
191 Ok(())
192 }
193 Err(_) => Err(ack),
194 }
195 }
196
197 /// Asks the vm to finish its pending work and shut down gracefully, the
198 /// worker will send a [WorkerMessage::Shutdown] for the current session

Callers 1

dispatch_worker_evtMethod · 0.80

Calls 2

gen_dispatch_idMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected