proksi 0.6.0

A batteries-included reverse proxy with automatic HTTPS using Cloudflare Pingora and Let's Encrypt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use once_cell::sync::OnceCell;
use std::sync::Arc;

use super::store_trait::Store;

static GLOBAL_STORE: OnceCell<Arc<dyn Store>> = OnceCell::new();

pub fn init_store<S: Store>(store: S) {
    if GLOBAL_STORE.set(Arc::new(store)).is_err() {
        tracing::error!("failed to initialize global store");
    }
}

pub fn get_store() -> &'static Arc<dyn Store> {
    GLOBAL_STORE.get().expect("Global store not initialized")
}