diff options
author | FxQnLr <[email protected]> | 2023-10-29 20:30:01 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2023-10-29 20:30:01 +0100 |
commit | 84c32953ae5f52be44af4b48381747f55cb04f4a (patch) | |
tree | 6b7ffd4d7ac7b89bb9bf169be7ba6d266f79d650 /src/main.rs | |
parent | 0cca10290d089aabac8f2e4356cfaf80f06ae194 (diff) | |
download | webol-84c32953ae5f52be44af4b48381747f55cb04f4a.tar webol-84c32953ae5f52be44af4b48381747f55cb04f4a.tar.gz webol-84c32953ae5f52be44af4b48381747f55cb04f4a.zip |
impl dashmap
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 545d8fe..762a817 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,12 +1,11 @@ | |||
1 | use std::collections::HashMap; | ||
2 | use std::env; | 1 | use std::env; |
3 | use std::sync::Arc; | 2 | use std::sync::Arc; |
4 | use axum::{Router, routing::post}; | 3 | use axum::{Router, routing::post}; |
5 | use axum::routing::{get, put}; | 4 | use axum::routing::{get, put}; |
5 | use dashmap::DashMap; | ||
6 | use sqlx::PgPool; | 6 | use sqlx::PgPool; |
7 | use time::util::local_offset; | 7 | use time::util::local_offset; |
8 | use tokio::sync::broadcast::{channel, Sender}; | 8 | use tokio::sync::broadcast::{channel, Sender}; |
9 | use tokio::sync::Mutex; | ||
10 | use tracing::{info, level_filters::LevelFilter}; | 9 | use tracing::{info, level_filters::LevelFilter}; |
11 | use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; | 10 | use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; |
12 | use crate::config::SETTINGS; | 11 | use crate::config::SETTINGS; |
@@ -51,9 +50,9 @@ async fn main() { | |||
51 | 50 | ||
52 | let (tx, _) = channel(32); | 51 | let (tx, _) = channel(32); |
53 | 52 | ||
54 | let ping_map: HashMap<String, (String, bool)> = HashMap::new(); | 53 | let ping_map: DashMap<String, (String, bool)> = DashMap::new(); |
55 | 54 | ||
56 | let shared_state = Arc::new(AppState { db, ping_send: tx, ping_map: Arc::new(Mutex::new(ping_map)) }); | 55 | let shared_state = Arc::new(AppState { db, ping_send: tx, ping_map: Arc::new(ping_map) }); |
57 | 56 | ||
58 | let app = Router::new() | 57 | let app = Router::new() |
59 | .route("/start", post(start)) | 58 | .route("/start", post(start)) |