pub struct ListenerPipelines { /* private fields */ }Expand description
Maps listener names to their resolved FilterPipelines.
Each pipeline is wrapped in ArcSwap so it can be atomically
replaced at runtime without blocking in-flight requests.
use std::{collections::HashMap, sync::Arc};
use praxis_filter::{FilterPipeline, FilterRegistry};
use praxis_protocol::ListenerPipelines;
let registry = FilterRegistry::with_builtins();
let pipeline = Arc::new(FilterPipeline::build(&mut [], ®istry).unwrap());
let mut map = HashMap::new();
map.insert("web".to_owned(), pipeline);
let pipelines = ListenerPipelines::new(map);
assert!(pipelines.get("web").is_some());
assert!(pipelines.get("missing").is_none());Implementations§
Source§impl ListenerPipelines
impl ListenerPipelines
Sourcepub fn new(pipelines: HashMap<String, Arc<FilterPipeline>>) -> Self
pub fn new(pipelines: HashMap<String, Arc<FilterPipeline>>) -> Self
Create from a map of listener name to pipeline.
Sourcepub fn get(&self, listener_name: &str) -> Option<&Arc<ArcSwap<FilterPipeline>>>
pub fn get(&self, listener_name: &str) -> Option<&Arc<ArcSwap<FilterPipeline>>>
Get the swappable pipeline for a listener by name.
Sourcepub fn swap(&self, listener_name: &str, new_pipeline: Arc<FilterPipeline>)
pub fn swap(&self, listener_name: &str, new_pipeline: Arc<FilterPipeline>)
Atomically replace the pipeline for a listener.
No-op if the listener name is not present.
use std::{collections::HashMap, sync::Arc};
use praxis_filter::{FilterPipeline, FilterRegistry};
use praxis_protocol::ListenerPipelines;
let registry = FilterRegistry::with_builtins();
let old = Arc::new(FilterPipeline::build(&mut [], ®istry).unwrap());
let new = Arc::new(FilterPipeline::build(&mut [], ®istry).unwrap());
let mut map = HashMap::new();
map.insert("web".to_owned(), old);
let pipelines = ListenerPipelines::new(map);
pipelines.swap("web", new);
pipelines.swap(
"nonexistent",
Arc::new(FilterPipeline::build(&mut [], ®istry).unwrap()),
);Sourcepub fn referenced_files(&self) -> Vec<PathBuf>
pub fn referenced_files(&self) -> Vec<PathBuf>
Every filesystem path any filter in any listener’s pipeline reads configuration from, de-duplicated.
Two listeners can share a filter chain, so the same document would otherwise appear more than once and be watched and hashed repeatedly.
Sourcepub fn listener_names(&self) -> impl Iterator<Item = &str>
pub fn listener_names(&self) -> impl Iterator<Item = &str>
Returns an iterator over listener names.
Auto Trait Implementations§
impl !RefUnwindSafe for ListenerPipelines
impl !UnwindSafe for ListenerPipelines
impl Freeze for ListenerPipelines
impl Send for ListenerPipelines
impl Sync for ListenerPipelines
impl Unpin for ListenerPipelines
impl UnsafeUnpin for ListenerPipelines
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more