use crate::engine::interfaces::{Layer, ProcessingStep};
use crate::layers::l4::loader::PreProcess;
use arc_swap::ArcSwap;
use dashmap::DashMap;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[cfg(feature = "console")]
use utoipa::ToSchema;
use validator::{Validate, ValidationErrors};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema)]
pub struct ApplicationConfig {
pub pipeline: ProcessingStep,
#[serde(skip)]
#[schema(ignore)]
pub protocol: String,
}
impl Validate for ApplicationConfig {
fn validate(&self) -> Result<(), ValidationErrors> {
use crate::layers::l4::validator;
validator::validate_flow_config(&self.pipeline, Layer::L7, &self.protocol)
}
}
impl PreProcess for ApplicationConfig {
fn pre_process(&mut self) {
}
fn set_context(&mut self, context: &str) {
self.protocol = context.to_owned();
}
}
pub static APPLICATION_REGISTRY: Lazy<ArcSwap<DashMap<String, Arc<ApplicationConfig>>>> =
Lazy::new(|| ArcSwap::new(Arc::new(DashMap::new())));
pub const SUPPORTED_APP_PROTOCOLS: &[&str] = &["httpx"];