From 21629749646e2087f8a0de124304d1095cffb9a2 Mon Sep 17 00:00:00 2001 From: Dario A Lencina-Talarico Date: Sun, 23 Jun 2024 23:59:21 -0400 Subject: [PATCH] updating base images (#160) * updating base images * update base image * cache build * fmt * make ci green again * pass linter --- bot/src/main.rs | 2 +- docker/Dockerfile.actix | 2 +- docker/Dockerfile.yew | 2 +- docker/base_images/Dockerfile.actix | 2 +- docker/base_images/Dockerfile.yew | 2 +- docker/docker-compose.yaml | 7 +++++++ protobuf/build-env-rust.Dockerfile | 2 +- videocall-client/src/client/video_call_client.rs | 3 +-- videocall-client/src/connection/connection.rs | 4 +++- .../src/decode/hash_map_with_ordered_keys.rs | 12 ++++++------ .../src/decode/peer_decode_manager.rs | 15 +++++++++------ videocall-client/src/decode/peer_decoder.rs | 4 ++-- .../src/decode/video_decoder_with_buffer.rs | 2 +- 13 files changed, 35 insertions(+), 24 deletions(-) diff --git a/bot/src/main.rs b/bot/src/main.rs index ac7103ce..6b529630 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -70,7 +70,7 @@ async fn create_client( // rewrite whatever is in the protobuf so that it seems like it is coming from this bot if media_packet.email == echo_user { - media_packet.email = email.clone(); + media_packet.email.clone_from(&email); // send the protobuf back to the server let mut buf = Vec::new(); diff --git a/docker/Dockerfile.actix b/docker/Dockerfile.actix index 2ce3a123..70fdf46e 100644 --- a/docker/Dockerfile.actix +++ b/docker/Dockerfile.actix @@ -1,4 +1,4 @@ -FROM securityunion/rustlemania-api-base:1.72-slim +FROM securityunion/rustlemania-api-base:update-rust-7c189827 RUN rustup component add clippy RUN rustup component add rustfmt diff --git a/docker/Dockerfile.yew b/docker/Dockerfile.yew index 08b7a6ae..c63f950b 100644 --- a/docker/Dockerfile.yew +++ b/docker/Dockerfile.yew @@ -1,4 +1,4 @@ -FROM securityunion/yew:1.72-slim +FROM securityunion/yew:update-rust-7c189827 RUN rustup component add clippy RUN rustup component add rustfmt diff --git a/docker/base_images/Dockerfile.actix b/docker/base_images/Dockerfile.actix index 8d86b6dc..bfd0b226 100644 --- a/docker/base_images/Dockerfile.actix +++ b/docker/base_images/Dockerfile.actix @@ -1,4 +1,4 @@ -FROM rust:1.72-slim +FROM rust:1.79-slim RUN apt-get --yes update && apt-get --yes install curl git pkg-config libssl-dev RUN curl https://github.com/amacneil/dbmate/releases/download/v2.4.0/dbmate-linux-amd64 -L -o /usr/bin/dbmate && chmod +x /usr/bin/dbmate diff --git a/docker/base_images/Dockerfile.yew b/docker/base_images/Dockerfile.yew index 903c7c8e..69a249ad 100644 --- a/docker/base_images/Dockerfile.yew +++ b/docker/base_images/Dockerfile.yew @@ -1,4 +1,4 @@ -FROM rust:1.72-slim as development +FROM rust:1.79-slim as development RUN rustup default nightly-2023-12-13 RUN apt-get --yes update && apt-get --yes install git pkg-config libssl-dev diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 9efb345f..7c8ee548 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -8,6 +8,8 @@ services: target: /app - /app/target - rustlemania-yew-ui-cargo-registry-cache:/usr/local/cargo/registry + - rustlemania-yew-ui-cache:/app/yew-ui/target + build: dockerfile: ../docker/Dockerfile.yew @@ -51,6 +53,7 @@ services: target: /app - /app/target - rustlemania-actix-web-cargo-registry-cache:/usr/local/cargo/registry + - rustlemania-actix-web-target-cache:/app/actix-api/target depends_on: - postgres @@ -76,6 +79,7 @@ services: target: /app - /app/target - rustlemania-actix-webtransport-cargo-registry-cache:/usr/local/cargo/registry + - rustlemania-actix-webtransport-cache:/app/actix-api/target depends_on: - nats @@ -110,3 +114,6 @@ volumes: rustlemania-actix-web-cargo-registry-cache: rustlemania-actix-webtransport-cargo-registry-cache: rustlemania-yew-ui-cargo-registry-cache: + rustlemania-actix-web-target-cache: + rustlemania-actix-webtransport-cache: + rustlemania-yew-ui-cache: diff --git a/protobuf/build-env-rust.Dockerfile b/protobuf/build-env-rust.Dockerfile index 74e82126..cd01588d 100644 --- a/protobuf/build-env-rust.Dockerfile +++ b/protobuf/build-env-rust.Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.72-slim +FROM rust:1.79-slim ENV DEBIAN_FRONTEND=noninteractive ARG USER ARG UID diff --git a/videocall-client/src/client/video_call_client.rs b/videocall-client/src/client/video_call_client.rs index 5083ea73..e26aae37 100644 --- a/videocall-client/src/client/video_call_client.rs +++ b/videocall-client/src/client/video_call_client.rs @@ -177,7 +177,7 @@ impl VideoCallClient { Ok(mut inner) => { inner.peer_decode_manager.run_peer_monitor(); on_connection_lost.emit(()); - }, + } Err(_) => { error!("Unable to borrow inner -- not starting peer monitor"); } @@ -185,7 +185,6 @@ impl VideoCallClient { } }) }, - }; info!( "webtransport connect = {}", diff --git a/videocall-client/src/connection/connection.rs b/videocall-client/src/connection/connection.rs index 0685a424..99da5bef 100644 --- a/videocall-client/src/connection/connection.rs +++ b/videocall-client/src/connection/connection.rs @@ -58,7 +58,9 @@ impl Connection { let mut connection = Self { task: Rc::new(Task::connect(webtransport, options)?), heartbeat: None, - heartbeat_monitor: Some(Interval::new(5000, move || {monitor.emit(());})), + heartbeat_monitor: Some(Interval::new(5000, move || { + monitor.emit(()); + })), status, aes, }; diff --git a/videocall-client/src/decode/hash_map_with_ordered_keys.rs b/videocall-client/src/decode/hash_map_with_ordered_keys.rs index 5cfb6861..8ad878fe 100644 --- a/videocall-client/src/decode/hash_map_with_ordered_keys.rs +++ b/videocall-client/src/decode/hash_map_with_ordered_keys.rs @@ -77,20 +77,20 @@ impl HashMapWithOrderedKeys { pub fn remove_if(&mut self, predicate: F) where - F: Fn(&mut V) -> bool + F: Fn(&mut V) -> bool, { let mut keys_to_remove = Vec::new(); - for key in &self.keys{ + for key in &self.keys { if let Some(value) = self.map.get_mut(key) { - if !predicate(value){ + if !predicate(value) { keys_to_remove.push(key.clone()); - } + } } } - for key in &keys_to_remove { - self.map.remove(&key); + for key in &keys_to_remove { + self.map.remove(key); self.keys.retain(|k| k != key); } } diff --git a/videocall-client/src/decode/peer_decode_manager.rs b/videocall-client/src/decode/peer_decode_manager.rs index 0bbea788..f4474c13 100644 --- a/videocall-client/src/decode/peer_decode_manager.rs +++ b/videocall-client/src/decode/peer_decode_manager.rs @@ -76,7 +76,7 @@ impl Peer { video_canvas_id, screen_canvas_id, aes, - heartbeat_count: 1 + heartbeat_count: 1, } } @@ -148,7 +148,7 @@ impl Peer { MediaType::HEARTBEAT => Ok(( media_type, DecodeStatus { - rendered: false, + _rendered: false, first_frame: false, }, )), @@ -160,12 +160,15 @@ impl Peer { } pub fn check_heartbeat(&mut self) -> bool { - if self.heartbeat_count != 0 { + if self.heartbeat_count != 0 { self.heartbeat_count = 0; return true; } - debug!("---@@@--- detected heartbeat stop for {}", self.email.clone()); - return false; + debug!( + "---@@@--- detected heartbeat stop for {}", + self.email.clone() + ); + false } } @@ -214,7 +217,7 @@ impl PeerDecodeManager { Ok((MediaType::HEARTBEAT, _)) => { peer.on_heartbeat(); Ok(()) - }, + } Ok((media_type, decode_status)) => { if decode_status.first_frame { self.on_first_frame.emit((email.clone(), media_type)); diff --git a/videocall-client/src/decode/peer_decoder.rs b/videocall-client/src/decode/peer_decoder.rs index 1e81b23e..319fd64b 100644 --- a/videocall-client/src/decode/peer_decoder.rs +++ b/videocall-client/src/decode/peer_decoder.rs @@ -36,7 +36,7 @@ use web_sys::{MediaStreamTrackGenerator, MediaStreamTrackGeneratorInit}; use web_sys::{VideoDecoderConfig, VideoDecoderInit, VideoFrame}; pub struct DecodeStatus { - pub rendered: bool, + pub _rendered: bool, pub first_frame: bool, } @@ -88,7 +88,7 @@ macro_rules! impl_decode { } } Ok(DecodeStatus { - rendered: true, + _rendered: true, first_frame, }) }}; diff --git a/videocall-client/src/decode/video_decoder_with_buffer.rs b/videocall-client/src/decode/video_decoder_with_buffer.rs index 5e795008..071ebbab 100644 --- a/videocall-client/src/decode/video_decoder_with_buffer.rs +++ b/videocall-client/src/decode/video_decoder_with_buffer.rs @@ -42,7 +42,7 @@ impl VideoDecoderWithBuffer { let is_future_frame = new_sequence_number > sequence; let is_future_i_frame = is_future_frame && frame_type == EncodedVideoChunkType::Key; let is_next_frame = new_sequence_number == sequence + 1; - let next_frame_already_cached = self.cache.get(&(sequence + 1)).is_some(); + let next_frame_already_cached = self.cache.contains_key(&(sequence + 1)); if is_future_i_frame || is_next_frame { self.video_decoder.decode(image); self.sequence = Some(new_sequence_number);