MCPcopy Create free account
hub / github.com/ElementsProject/lightning / run

Method run

plugins/src/lib.rs:881–909  ·  view source on GitHub ↗

Run the plugin until we get a shutdown command.

(
        self,
        mut receiver: tokio::sync::mpsc::Receiver<serde_json::Value>,
        mut input: FramedRead<I, JsonRpcCodec>,
        output: Arc<Mutex<FramedWrite<O, JsonCodec>>>,
    )

Source from the content-addressed store, hash-verified

879{
880 /// Run the plugin until we get a shutdown command.
881 async fn run<I, O>(
882 self,
883 mut receiver: tokio::sync::mpsc::Receiver<serde_json::Value>,
884 mut input: FramedRead<I, JsonRpcCodec>,
885 output: Arc<Mutex<FramedWrite<O, JsonCodec>>>,
886 ) -> Result<(), Error>
887 where
888 I: Send + AsyncReadExt + Unpin,
889 O: Send + AsyncWriteExt + Unpin,
890 {
891 loop {
892 // If we encounter any error reading or writing from/to
893 // the master we hand them up, so we can return control to
894 // the user-code, which may require some cleanups or
895 // similar.
896 tokio::select! {
897 e = self.dispatch_one(&mut input, &self.plugin) => {
898 if let Err(e) = e {
899 return Err(e)
900 }
901 },
902 v = receiver.recv() => {
903 output.lock().await.send(
904 v.context("internal communication error")?
905 ).await?;
906 },
907 }
908 }
909 }
910
911 /// Dispatch one server-side event and then return. Just so we
912 /// have a nicer looking `select` statement in `run` :-)

Callers 2

startMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected