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.
Called by the server during startup after building filter pipelines
from the loaded configuration. Each pipeline is wrapped in ArcSwap
for atomic replacement during hot reloads.
Sourcepub fn with_protocols(
pipelines: HashMap<String, Arc<FilterPipeline>>,
protocols: HashMap<String, ProtocolKind>,
) -> Self
pub fn with_protocols( pipelines: HashMap<String, Arc<FilterPipeline>>, protocols: HashMap<String, ProtocolKind>, ) -> Self
Create from a map of listener name to pipeline, recording the protocol each listener’s pipeline was resolved for.
use std::{collections::HashMap, sync::Arc};
use praxis_core::config::ProtocolKind;
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("db".to_owned(), pipeline);
let mut protocols = HashMap::new();
protocols.insert("db".to_owned(), ProtocolKind::Tcp);
let pipelines = ListenerPipelines::with_protocols(map, protocols);
assert_eq!(pipelines.protocol("db"), Some(ProtocolKind::Tcp));Sourcepub fn protocol(&self, listener_name: &str) -> Option<ProtocolKind>
pub fn protocol(&self, listener_name: &str) -> Option<ProtocolKind>
The protocol a listener’s pipelines are resolved for, if recorded.
Fixed at construction: a swap never changes it.
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.
Called by protocol adapters on every request to access the filter
pipeline. The returned ArcSwap reference allows protocol adapters
to load the current pipeline without blocking reload operations.
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.
Used during config reload to iterate over all listeners when swapping pipelines or collecting referenced files for watching.