athena_rs 3.26.2

Hyper performant polyglot Database driver
Documentation
use anyhow::Result;
use serde_json::json;

#[cfg(feature = "cdc")]
pub async fn run_cdc_websocket_runtime() -> Result<()> {
    let _runtime = super::initialize_process_runtime();
    let context = super::load_runtime_bootstrap_from_env().await?;
    let port: u16 = 4053;
    let identity = super::install_process_daemon_identity("athena_cdc_websocket", None)?;

    crate::daemon::spawn_runtime_registry_heartbeat(
        context.bootstrap.app_state.clone(),
        "athena_cdc_websocket",
        Some(identity.daemon_id),
        vec!["cdc_websocket_server".to_string()],
        json!({
            "management_mode": "dedicated_worker",
            "runtime": "athena_cdc_websocket",
            "port": port,
        }),
    );

    crate::cdc::websocket::websocket_server(
        port,
        context.config.get_cdc_allow_legacy_axum_wildcards(),
    )
    .await
    .map_err(|err| anyhow::anyhow!(err.to_string()))
}

#[cfg(not(feature = "cdc"))]
pub async fn run_cdc_websocket_runtime() -> Result<()> {
    anyhow::bail!("athena_cdc_websocket requires the `cdc` feature")
}

pub async fn run_client_pressure_worker_runtime() -> Result<()> {
    let _runtime = super::initialize_process_runtime();
    let context = super::load_runtime_bootstrap_from_env().await?;
    let identity = super::install_process_daemon_identity("athena_client_pressure_worker", None)?;

    crate::daemon::spawn_runtime_registry_heartbeat(
        context.bootstrap.app_state,
        "athena_client_pressure_worker",
        Some(identity.daemon_id),
        vec!["client_pressure_worker".to_string()],
        json!({
            "management_mode": "dedicated_worker",
            "runtime": "athena_client_pressure_worker",
        }),
    );

    crate::features::client_pressure::run_pressure_worker(&context.config).await
}