]> git.puffer.fish Git - matthieu/nova.git/commitdiff
fix some things
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Sat, 6 Jul 2024 21:30:15 +0000 (01:30 +0400)
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Sat, 6 Jul 2024 21:30:15 +0000 (01:30 +0400)
exes/cache/src/main.rs
exes/rest/src/handler.rs
exes/rest/src/lib.rs

index c0dff6d3d774f400fa4e0fba5248d24c2467422e..6be325deb350409646721acbf64d97837b22dc9a 100644 (file)
@@ -65,7 +65,7 @@ async fn listen(sub: &mut Subscriber, cache: &mut Cache, features: Vec<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | 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<String>)
             | DispatchEvent::AutoModerationRuleUpdate(_)
                 if features.contains(&"automoderation_cache".to_string()) =>
             {
-                cache.automoderation.handle(event);
+                cache.automoderation.handle(event).await;
             }
 
             // Voice State
index a74c7c8119a4b27ab1bdb58f46a5c663785cbc6f..364ca3c2e411a15a5828617f7e8f7eae904515e1 100644 (file)
@@ -33,37 +33,37 @@ lazy_static! {
             .init()
     };
     static ref UPSTREAM_CALLS: Counter<u64> = {
-        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<u64> = {
-        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<u64> = {
-        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<u64> = {
-        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<u64> = {
-        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<u64> = {
-        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)],
     );
index 917f5247c43e4242ccccc88663580784c906ef46..58f232bff958690e10d1388f68b07c611168389a 100644 (file)
@@ -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| {