use crate::quota::Quota; use crate::storage::Store; use std::sync::Arc; pub struct AppState { pub store: Store, pub irail_http: reqwest::Client, pub irail_quota: Arc, pub villo_quota: Arc, pub train_refresh: tokio::sync::mpsc::Sender>, } impl AppState { pub fn new( store: Store, train_refresh: tokio::sync::mpsc::Sender>, ) -> Arc { Arc::new(Self { store, irail_http: reqwest::Client::builder() .user_agent("stibble (git.devtechnica.com/pebbletechnica/stibble)") .timeout(std::time::Duration::from_secs(10)) .build() .expect("irail http client"), irail_quota: Arc::new(Quota::new(180, 5000)), villo_quota: Arc::new(Quota::new(10, 5000)), train_refresh, }) } }