From: Matthieu Pignolet Date: Sat, 6 Jul 2024 21:30:15 +0000 (+0400) Subject: fix some things X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=91e622c59e2778073d94515e22b383b5c61624f9;p=matthieu%2Fnova.git fix some things --- diff --git a/exes/cache/src/main.rs b/exes/cache/src/main.rs index c0dff6d..6be325d 100644 --- a/exes/cache/src/main.rs +++ b/exes/cache/src/main.rs @@ -65,7 +65,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::ChannelUpdate(_) if features.contains(&"channels_cache".to_string()) => { - cache.channels.handle(event); + cache.channels.handle(event).await; } // Guild Cache @@ -81,7 +81,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::CommandPermissionsUpdate(_) if features.contains(&"guilds_cache".to_string()) => { - cache.guilds.handle(event); + cache.guilds.handle(event).await; } // Guild Scheduled event @@ -92,7 +92,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::GuildScheduledEventUserRemove(_) if features.contains(&"guild_schedules_cache".to_string()) => { - cache.guild_schedules.handle(event); + cache.guild_schedules.handle(event).await; } // Stage events @@ -101,7 +101,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::StageInstanceUpdate(_) if features.contains(&"stage_instances_cache".to_string()) => { - cache.stage_instances.handle(event); + cache.stage_instances.handle(event).await; } // Integration events @@ -111,7 +111,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::InteractionCreate(_) if features.contains(&"integrations_cache".to_string()) => { - cache.integrations.handle(event); + cache.integrations.handle(event).await; } // Member events @@ -122,14 +122,14 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::UserUpdate(_) if features.contains(&"members_cache".to_string()) => { - cache.members.handle(event); + cache.members.handle(event).await; } // Ban cache DispatchEvent::BanAdd(_) | DispatchEvent::BanRemove(_) if features.contains(&"bans_cache".to_string()) => { - cache.bans.handle(event); + cache.bans.handle(event).await; } // Reaction cache @@ -139,7 +139,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::ReactionRemoveEmoji(_) if features.contains(&"reactions_cache".to_string()) => { - cache.reactions.handle(event); + cache.reactions.handle(event).await; } // Message cache @@ -149,7 +149,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::MessageUpdate(_) if features.contains(&"messages_cache".to_string()) => { - cache.messages.handle(event); + cache.messages.handle(event).await; } // Thread cache @@ -161,14 +161,14 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::ThreadUpdate(_) if features.contains(&"threads_cache".to_string()) => { - cache.threads.handle(event); + cache.threads.handle(event).await; } // Invite cache DispatchEvent::InviteCreate(_) | DispatchEvent::InviteDelete(_) if features.contains(&"invites_cache".to_string()) => { - cache.invites.handle(event); + cache.invites.handle(event).await; } // Roles cache @@ -177,7 +177,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::RoleUpdate(_) if features.contains(&"roles_cache".to_string()) => { - cache.roles.handle(event); + cache.roles.handle(event).await; } // Automod rules @@ -186,7 +186,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec) | DispatchEvent::AutoModerationRuleUpdate(_) if features.contains(&"automoderation_cache".to_string()) => { - cache.automoderation.handle(event); + cache.automoderation.handle(event).await; } // Voice State diff --git a/exes/rest/src/handler.rs b/exes/rest/src/handler.rs index a74c7c8..364ca3c 100644 --- a/exes/rest/src/handler.rs +++ b/exes/rest/src/handler.rs @@ -33,37 +33,37 @@ lazy_static! { .init() }; static ref UPSTREAM_CALLS: Counter = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_counter("rest.upstream_http_requests_total") .with_description("Amount of requests sent to discord") .init() }; static ref TICKET_CALLS: Counter = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_counter("rest.ticket_http_requests_total") .with_description("Amount of requests sent to the ratelimiter") .init() }; static ref HEADERS_SUBMIT_CALLS: Counter = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_counter("rest.header_submit_http_requests_total") .with_description("Amount of requests sent to the ratelimiter") .init() }; static ref UPSTREAM_TIMES: Histogram = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_histogram("rest.upstream_http_request_duration_miliseconds") .with_description("Time took to request discord") .init() }; static ref TICKET_TIMES: Histogram = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_histogram("rest.ticket_http_request_duration_miliseconds") .with_description("Time took to get a ticket from the ratelimiter") .init() }; static ref HEADERS_SUBMIT_TIMES: Histogram = { - global::meter(&METER_NAME) + global::meter(**&METER_NAME) .u64_histogram("rest.header_submit_http_request_duration_miliseconds") .with_description("Time took to get a ticket from the ratelimiter") .init() @@ -230,10 +230,10 @@ pub async fn handle_request( (bucket, uri_string, path_name(&path)) }; - REQUESTS.add(&cx, 1, &[KeyValue::new("bucket", name)]); + REQUESTS.add( 1, &[KeyValue::new("bucket", name)]); let ticket_start = SystemTime::now(); - TICKET_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]); + TICKET_CALLS.add(1, &[KeyValue::new("bucket", name)]); // waits for the request to be authorized match ratelimiter .ticket(bucket.clone()) @@ -243,7 +243,6 @@ pub async fn handle_request( Ok(_) => { #[allow(clippy::cast_possible_truncation)] TICKET_TIMES.record( - &cx, ticket_start.elapsed()?.as_millis() as u64, &[KeyValue::new("bucket", name)], ); @@ -291,12 +290,11 @@ pub async fn handle_request( *request.uri_mut() = uri; let span = debug_span!("upstream request to discord"); let upstream_start = SystemTime::now(); - UPSTREAM_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]); + UPSTREAM_CALLS.add(1, &[KeyValue::new("bucket", name)]); let resp = match client.request(request).instrument(span).await { Ok(response) => { #[allow(clippy::cast_possible_truncation)] UPSTREAM_TIMES.record( - &cx, upstream_start.elapsed()?.as_millis() as u64, &[KeyValue::new("bucket", name)], ); @@ -322,14 +320,13 @@ pub async fn handle_request( .collect(); let headers_start = SystemTime::now(); - HEADERS_SUBMIT_CALLS.add(&cx, 1, &[KeyValue::new("bucket", name)]); + HEADERS_SUBMIT_CALLS.add( 1, &[KeyValue::new("bucket", name)]); ratelimiter .submit_headers(bucket.clone(), headers) .instrument(info_span!("submitting headers")) .await?; #[allow(clippy::cast_possible_truncation)] HEADERS_SUBMIT_TIMES.record( - &cx, headers_start.elapsed()?.as_millis() as u64, &[KeyValue::new("bucket", name)], ); diff --git a/exes/rest/src/lib.rs b/exes/rest/src/lib.rs index 917f524..58f232b 100644 --- a/exes/rest/src/lib.rs +++ b/exes/rest/src/lib.rs @@ -47,11 +47,12 @@ impl Component for ReverseProxyServer { )); let https = hyper_rustls::HttpsConnectorBuilder::new() .with_native_roots() + .expect("Native roots not available") .https_or_http() .enable_http1() .build(); - let client: Client<_, hyper::Body> = Client::builder().build(https); + let client: Client<_, hyper::body::Body> = Client::builder().build(https); let token = settings.config.discord.token.clone(); let config = settings.config.clone(); let service_fn = make_service_fn(move |_: &AddrStream| {