diff --git a/plugins/reaction-plugin-virtual/src/main.rs b/plugins/reaction-plugin-virtual/src/main.rs index ee551ec..3b06cbc 100644 --- a/plugins/reaction-plugin-virtual/src/main.rs +++ b/plugins/reaction-plugin-virtual/src/main.rs @@ -1,7 +1,8 @@ use std::collections::{BTreeMap, BTreeSet}; use reaction_plugin::{ - ActionImpl, Exec, Hello, Line, Manifest, PluginInfo, RemoteResult, StreamImpl, Value, + ActionImpl, Exec, Hello, Line, Manifest, PersistData, PluginInfo, RemoteResult, StreamImpl, + Value, }; use remoc::{rch::mpsc, rtc}; @@ -18,7 +19,7 @@ struct Plugin { } impl PluginInfo for Plugin { - async fn manifest(&self) -> Result { + async fn manifest(&mut self, _data: PersistData) -> Result { Ok(Manifest { hello: Hello::hello(), streams: BTreeSet::from(["virtual".into()]), diff --git a/plugins/reaction-plugin/src/lib.rs b/plugins/reaction-plugin/src/lib.rs index fcf8950..036f43b 100644 --- a/plugins/reaction-plugin/src/lib.rs +++ b/plugins/reaction-plugin/src/lib.rs @@ -35,7 +35,8 @@ use std::{ }; use remoc::{ - Connect, rch, + Connect, + rch::{self, mpsc}, rtc::{self, Server}, }; use serde::{Deserialize, Serialize}; @@ -46,7 +47,7 @@ use tokio::io::{stdin, stdout}; #[rtc::remote] pub trait PluginInfo { /// Return the manifest of the plugin. - async fn manifest(&self) -> Result; + async fn manifest(&mut self, data: PersistData) -> Result; /// Return one stream of a given type if it exists async fn stream_impl( @@ -158,6 +159,16 @@ pub enum Value { Object(BTreeMap), } +/// Data persisted by reaction for the plugin. +/// This is persisted as a single JSON file by reaction, so it is not suitable for big sizes of data. +#[derive(Serialize, Deserialize)] +pub struct PersistData { + /// Data persisted by the plugin in a previous run + pub persisted_data: Value, + /// Sender of data to be persisted by the plugin for a previous run + pub persist_data: mpsc::Sender, +} + #[derive(Serialize, Deserialize)] pub struct StreamImpl { pub stream: rch::mpsc::Receiver, diff --git a/src/concepts/plugin.rs b/src/concepts/plugin.rs index 4884046..fa9b7fb 100644 --- a/src/concepts/plugin.rs +++ b/src/concepts/plugin.rs @@ -112,6 +112,7 @@ impl Plugin { } Command::new(&self.path) }; + command.arg("serve"); debug!( "plugin {}: running command: {:?}", self.name,