Skip to content

Commit

Permalink
Import changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GPeaky committed Oct 21, 2024
1 parent 672f5ef commit c24b0a7
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 75 deletions.
4 changes: 2 additions & 2 deletions crates/api/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub(crate) use local_tracing::*;

mod local_tracing;

pub(crate) use local_tracing::*;
4 changes: 2 additions & 2 deletions crates/api/src/handlers/admin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub(crate) use conn::*;

mod conn;

pub(crate) use conn::*;
8 changes: 4 additions & 4 deletions crates/api/src/handlers/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) use discord::*;
pub(crate) use user::*;
pub(crate) use verify::*;

mod discord;
mod user;
mod verify;

pub(crate) use discord::*;
pub(crate) use user::*;
pub(crate) use verify::*;
6 changes: 4 additions & 2 deletions crates/api/src/handlers/championships/stream.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{
pin::Pin,
task::{Context, Poll},
};

use garde::Validate;
use ntex::{
Expand Down
4 changes: 2 additions & 2 deletions crates/api/src/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use ntex::web::HttpResponse;

pub(crate) mod admin;
pub(crate) mod auth;
pub(crate) mod championships;
pub(crate) mod user;

use ntex::web::HttpResponse;

pub(crate) async fn system_health_check() -> HttpResponse {
HttpResponse::Ok().finish()
}
4 changes: 2 additions & 2 deletions crates/api/src/handlers/user/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub(crate) mod admin;

use garde::Validate;
use ntex::web::{
types::{Json, State},
Expand All @@ -11,8 +13,6 @@ use structs::{UserProfileData, UserUpdateData};

use crate::states::AppState;

pub(crate) mod admin;

#[inline]
pub(crate) async fn get(req: HttpRequest, state: State<AppState>) -> AppResult<HttpResponse> {
let user = req.user()?;
Expand Down
8 changes: 4 additions & 4 deletions crates/api/src/middlewares/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub(crate) use admin::*;
pub(crate) use authenticated::*;
pub(crate) use login::*;

mod admin;
mod authenticated;
mod login;

pub(crate) use admin::*;
pub(crate) use authenticated::*;
pub(crate) use login::*;
6 changes: 3 additions & 3 deletions crates/api/src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub(crate) use admin::*;
pub(crate) use api::*;

mod admin;
mod api;

pub(crate) use admin::*;
pub(crate) use api::*;
4 changes: 2 additions & 2 deletions crates/api/src/states/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub(crate) use app::*;

mod app;

pub(crate) use app::*;
8 changes: 4 additions & 4 deletions crates/db/src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod championship;
mod driver;
mod user;

use std::sync::Arc;

use driver::DriverCache;

use self::{championship::ChampionshipCache, user::UserCache};

mod championship;
mod driver;
mod user;

const CACHE_CAPACITY: usize = 2_000;

/// Caching layer for users, championships, and tokens.
Expand Down
4 changes: 2 additions & 2 deletions crates/db/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod cache;

use std::{ops::DerefMut, str::FromStr};

use cache::ServiceCache;
Expand All @@ -11,8 +13,6 @@ use tracing::info;

pub use cache::EntityCache;

mod cache;

embed_migrations!("migrations");

/// Encapsulates Postgres database connections.
Expand Down
12 changes: 6 additions & 6 deletions crates/entities/src/entities.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod championship;
mod driver;
mod race;
mod result;
mod user;

pub use championship::*;
pub use driver::*;
#[allow(unused)]
pub use race::*;
#[allow(unused)]
pub use result::*;
pub use user::*;

mod championship;
mod driver;
mod race;
mod result;
mod user;
16 changes: 8 additions & 8 deletions crates/error/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
mod championship;
mod common;
mod driver;
mod f1;
mod firewall;
mod token;
mod user;

use deadpool_postgres::{tokio_postgres::Error as PgError, PoolError};
use ntex::{
http::{
Expand All @@ -17,14 +25,6 @@ pub use firewall::*;
pub use token::*;
pub use user::*;

mod championship;
mod common;
mod driver;
mod f1;
mod firewall;
mod token;
mod user;

pub type AppResult<T> = Result<T, AppError>;

// TODO: Handle 3rd party errors in a better way
Expand Down
7 changes: 4 additions & 3 deletions crates/id-generator/src/id_generator.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#![feature(portable_simd)]
use ahash::AHashSet;
use parking_lot::Mutex;
use ring::rand::{SecureRandom, SystemRandom};
use std::{
ops::Range,
simd::{i32x16, num::SimdInt, Simd},
};

use ahash::AHashSet;
use parking_lot::Mutex;
use ring::rand::{SecureRandom, SystemRandom};

const IDS_POOL_SIZE: usize = 1024;

/// A structure to manage a set of bits efficiently.
Expand Down
12 changes: 6 additions & 6 deletions crates/intelli-core/src/repositories/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub use championship::*;
pub use discord::*;
pub use driver::*;
pub use server::*;
pub use user::*;

mod championship;
mod discord;
mod driver;
mod server;
mod user;

pub use championship::*;
pub use discord::*;
pub use driver::*;
pub use server::*;
pub use user::*;
10 changes: 5 additions & 5 deletions crates/intelli-core/src/services/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub use championship::*;
pub use driver::*;
pub use email::*;
pub use user::*;

mod championship;
mod driver;
mod email;
mod user;

pub use championship::*;
pub use driver::*;
pub use email::*;
pub use user::*;
12 changes: 6 additions & 6 deletions crates/structs/src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub use auth::*;
pub use championship::*;
pub use server::*;
pub use templates::*;
pub use user::*;

mod auth;
mod championship;
mod server;
mod templates;
mod user;

pub use auth::*;
pub use championship::*;
pub use server::*;
pub use templates::*;
pub use user::*;
2 changes: 1 addition & 1 deletion crates/telemetry/src/f1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// -------------- ORIGINAL GAME ----------------
// ---------------------------------------------

use core::str;
use std::str;

use error::{AppError, ChampionshipError};

Expand Down
3 changes: 2 additions & 1 deletion crates/telemetry/src/firewall.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{net::IpAddr, process::Command as StdCommand, str};

use ahash::AHashMap;
use error::{AppResult, FirewallError};
use regex::Regex;
use std::{net::IpAddr, process::Command as StdCommand, str};
use tokio::process::Command;
use tokio::sync::RwLock;
use tracing::{error, warn};
Expand Down
3 changes: 2 additions & 1 deletion crates/telemetry/src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::{ops::Deref, sync::Arc, time::Duration};

use ahash::{AHashMap, AHashSet};
use ntex::{
time::interval,
util::{Bytes, BytesMut},
};
use parking_lot::{Mutex, RwLock};
use prost::Message;
use std::{ops::Deref, sync::Arc, time::Duration};
use tokio::sync::{
broadcast::{Receiver, Sender},
oneshot,
Expand Down
12 changes: 8 additions & 4 deletions crates/token_manager/src/persistence.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::{
collections::VecDeque,
fs::{File, OpenOptions},
io::{Read, Write},
mem::size_of,
};

use dashmap::DashMap;
use std::collections::VecDeque;
use std::fs::{File, OpenOptions};
use std::io::{Read, Write};
use std::mem::size_of;

use utils::current_timestamp_s;

use crate::token::{Header, Token, TokenEntry};
Expand Down
3 changes: 2 additions & 1 deletion crates/token_manager/src/token.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::slice;

use base64_simd::{Out, URL_SAFE_NO_PAD};
use error::{AppResult, TokenError};
use ring::rand::{SecureRandom, SystemRandom};

use error::{AppResult, TokenError};

#[repr(C)]
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Token([u8; 16]);
Expand Down
9 changes: 5 additions & 4 deletions crates/token_manager/src/token_manager.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
mod persistence;
mod token;

use std::{collections::VecDeque, time::Duration};

use dashmap::DashMap;
use error::{AppResult, TokenError};
use token::TokenEntry;

mod persistence;
mod token;

pub use token::{Token, TokenIntent};
use tokio::{task, time::sleep};
use utils::current_timestamp_s;

pub use token::{Token, TokenIntent};

const MAX_TOKENS_PER_USER: usize = 10;
const PURGE_INTERVAL: Duration = Duration::from_secs(900);

Expand Down

0 comments on commit c24b0a7

Please sign in to comment.