faucet-server 2.1.0

Welcome to Faucet, your go-to solution for deploying Plumber APIs and Shiny Applications with blazing speed and efficiency. Faucet is a high-performance server built with Rust, offering Round Robin and Round Robin + IP Hash load balancing for seamless scaling and distribution of your R applications. Whether you're a data scientist, developer, or DevOps enthusiast, Faucet streamlines the deployment process, making it easier than ever to manage replicas and balance loads effectively.
Documentation
use std::sync::{atomic::AtomicI64, OnceLock};

pub static CORRENT_CONNECTIONS: OnceLock<AtomicI64> = OnceLock::new();

pub fn add_connection() {
    CORRENT_CONNECTIONS
        .get_or_init(|| AtomicI64::new(0))
        .fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}

pub fn remove_connection() {
    CORRENT_CONNECTIONS
        .get_or_init(|| unreachable!())
        .fetch_sub(1, std::sync::atomic::Ordering::SeqCst);
}

pub fn current_connections() -> i64 {
    CORRENT_CONNECTIONS
        .get_or_init(|| AtomicI64::new(0))
        .load(std::sync::atomic::Ordering::SeqCst)
}