From b14f78152813041d04a0fffa76154e72d916838f Mon Sep 17 00:00:00 2001 From: ppom Date: Sun, 7 Dec 2025 12:00:00 +0100 Subject: [PATCH] cluster: use reaction_plugin's PatternLine --- plugins/reaction-plugin-cluster/src/cluster.rs | 10 +--------- plugins/reaction-plugin-cluster/src/main.rs | 9 +++------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/plugins/reaction-plugin-cluster/src/cluster.rs b/plugins/reaction-plugin-cluster/src/cluster.rs index 5992d18..7caece5 100644 --- a/plugins/reaction-plugin-cluster/src/cluster.rs +++ b/plugins/reaction-plugin-cluster/src/cluster.rs @@ -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 diff --git a/plugins/reaction-plugin-cluster/src/main.rs b/plugins/reaction-plugin-cluster/src/main.rs index ed69cc5..026ad31 100644 --- a/plugins/reaction-plugin-cluster/src/main.rs +++ b/plugins/reaction-plugin-cluster/src/main.rs @@ -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, rx: mpsc::Receiver, } @@ -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, };