cluster: use reaction_plugin's PatternLine

This commit is contained in:
ppom 2025-12-07 12:00:00 +01:00
commit b14f781528
No known key found for this signature in database
2 changed files with 4 additions and 15 deletions

View file

@ -140,15 +140,7 @@ impl ActionInit {
) {
while let Ok(Some(m)) = self.rx.recv().await {
eprintln!("DEBUG action: received a message to send to connections");
let line = if m.match_.is_empty() {
self.send.clone()
} else {
(0..(m.match_.len()))
.zip(&self.patterns)
.fold(self.send.clone(), |acc, (i, pattern)| {
acc.replace(pattern, &m.match_[i])
})
};
let line = self.send.line(m.match_);
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
if self.self_
&& let Err(err) = own_stream_tx.send((line.clone(), now.clone())).await

View file

@ -7,7 +7,7 @@ use std::{
use iroh::{EndpointAddr, PublicKey, SecretKey, TransportAddr};
use reaction_plugin::{
ActionImpl, Exec, Hello, Line, Manifest, PluginInfo, RemoteResult, StreamImpl, Value,
main_loop, shutdown::ShutdownController, time::parse_duration,
line::PatternLine, main_loop, shutdown::ShutdownController, time::parse_duration,
};
use remoc::{rch::mpsc, rtc};
use serde::{Deserialize, Serialize};
@ -90,12 +90,10 @@ struct ActionOptions {
self_: bool,
}
#[derive(Serialize, Deserialize)]
struct ActionInit {
name: String,
send: String,
send: PatternLine,
self_: bool,
patterns: Vec<String>,
rx: mpsc::Receiver<Exec>,
}
@ -195,9 +193,8 @@ impl PluginInfo for Plugin {
let init_action = ActionInit {
name: format!("{}.{}.{}", stream_name, filter_name, action_name),
send: options.send,
send: PatternLine::new(options.send, patterns),
self_: options.self_,
patterns,
rx,
};