async fn new(config: config::AppConfig) -> Self {
        // initialize the global state Arc
        let gs = {
            // place config into it's own Arc so it can be shared to other portions of the
            // application without the entire global state
            //
            // this is mainly for the `Backend` module, as the `GlobalState` refers to the backend
            // structure and it wouldn't be wise to cyclically refer back to `GlobalState` inside
            // of the backend module
            let config = Arc::new(config);
            let metrics = metrics::Metrics::new().expect("metrics intialize");

            // may panic, but it's fine because it's before ping
            log::debug!("initializing cache...");
            let cache = create_dyn_cache(&config).await;

            // initialize the backend
            let backend = Backend::new(Arc::clone(&config));

            // create Atomic Reference Counter global state, that is passed to almost every aspect
            // of the application
            Arc::new(GlobalState {
                config,
                cache,
                backend,
                verifier: ArcSwap::from_pointee(tokens::TokenVerifier::new()),
                request_counter: atomic::AtomicUsize::new(0),
                metrics,
            })
        };

        Self { gs }
    }
/// Creates a new Application based on a config, as well as starting the backend HTTP and
/// pinging the backend.
Creates a new Application based on a config, as well as starting the backend HTTP and
pinging the backend.
Creates a new Application based on a config as well as starting the backend HTTP and pinging the backend .
async fn new(config: config::AppConfig) -> Self {
        // initialize the global state Arc
        let gs = {
            // place config into it's own Arc so it can be shared to other portions of the
            // application without the entire global state
            //
            // this is mainly for the `Backend` module, as the `GlobalState` refers to the backend
            // structure and it wouldn't be wise to cyclically refer back to `GlobalState` inside
            // of the backend module
            let config = Arc::new(config);
            let metrics = metrics::Metrics::new().expect("metrics intialize");
            // may panic, but it's fine because it's before ping
            log::debug!("initializing cache...");
            let cache = create_dyn_cache(&config).await;
            // initialize the backend
            let backend = Backend::new(Arc::clone(&config));
            // create Atomic Reference Counter global state, that is passed to almost every aspect
            // of the application
            Arc::new(GlobalState {
                config,
                cache,
                backend,
                verifier: ArcSwap::from_pointee(tokens::TokenVerifier::new()),
                request_counter: atomic::AtomicUsize::new(0),
                metrics,
            })
        };
        Self { gs }
    }
async fn new ( config : config :: AppConfig ) -> Self { // initialize the global state Arc let gs = { // place config into it's own Arc so it can be shared to other portions of the // application without the entire global state // // this is mainly for the `Backend` module, as the `GlobalState` refers to the backend // structure and it wouldn't be wise to cyclically refer back to `GlobalState` inside // of the backend module let config = Arc :: new ( config ) ; let metrics = metrics :: Metrics :: new ( ) . expect ( " " ) ; // may panic, but it's fine because it's before ping log :: debug ! ( " " ) ; let cache = create_dyn_cache ( & config ) . await ; // initialize the backend let backend = Backend :: new ( Arc :: clone ( & config ) ) ; // create Atomic Reference Counter global state, that is passed to almost every aspect // of the application Arc :: new ( GlobalState { config , cache , backend , verifier : ArcSwap :: from_pointee ( tokens :: TokenVerifier :: new ( ) ) , request_counter : atomic :: AtomicUsize :: new ( 0 ) , metrics , } ) } ; Self { gs } }
Creates a new Application based on a config, as well as starting the backend HTTP and
pinging the backend.
Creates a new Application based on a config as well as starting the backend HTTP and pinging the backend .
config
config::AppConfig