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<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointerSource§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more