Skip to content

Commit

Permalink
Remove Clone on ProcessEventRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
GamePad64 committed Feb 2, 2025
1 parent 804f421 commit 2ec4797
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions notifico-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use std::sync::Arc;
use tracing::{debug, error, info, warn};
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use url::Url;
use uuid::Uuid;

const COMPONENT_WORKER: &str = "worker";
const COMPONENT_UI: &str = "ui";
Expand Down Expand Up @@ -117,12 +118,10 @@ async fn main() {
#[allow(unused_assignments)]
let mut amqp_client = None;
if let Some(amqp_url) = args.amqp {
let container_name = format!("notifico-{}", Uuid::now_v7());

// Initialize AMQP client and replace local channels with AMQP ones
amqp_client = Some(
AmqpClient::connect(amqp_url, "wrk".to_string())
.await
.unwrap(),
);
amqp_client = Some(AmqpClient::connect(amqp_url, container_name).await.unwrap());

let (amqp_pipelines_tx, amqp_pipelines_rx) = amqp_client
.as_mut()
Expand Down
2 changes: 1 addition & 1 deletion notifico-core/src/pipeline/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::warn;
use utoipa::ToSchema;
use uuid::Uuid;

#[derive(Serialize, Deserialize, ToSchema, Debug, Clone)]
#[derive(Serialize, Deserialize, ToSchema, Debug)]
pub struct ProcessEventRequest {
#[serde(default = "Uuid::now_v7")]
pub id: Uuid,
Expand Down
7 changes: 3 additions & 4 deletions notifico-core/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::error::Error;
use std::ops::Deref;
use tokio::sync::oneshot;

#[derive(Debug, Clone, Copy)]
Expand All @@ -22,7 +21,7 @@ pub trait SenderChannel: Send + Sync {
async fn send_object(
&self,
message: Box<dyn Any + Send + Sync + 'static>,
) -> Result<Outcome, Box<dyn std::error::Error>>;
) -> Result<Outcome, Box<dyn Error>>;
fn message_kind(&self) -> MessageKind;
}

Expand Down Expand Up @@ -57,7 +56,7 @@ pub trait ReceiverChannel: Send + Sync {
impl dyn ReceiverChannel {
pub async fn receive<T>(&self) -> Result<(T, oneshot::Sender<Outcome>), Box<dyn Error>>
where
T: for<'de> Deserialize<'de> + Send + Sync + Clone + Sized + 'static,
T: for<'de> Deserialize<'de> + Send + Sync + Sized + 'static,
{
let result = self.receive_object().await?;
match self.message_kind() {
Expand All @@ -74,7 +73,7 @@ impl dyn ReceiverChannel {
}
MessageKind::Object => {
let message = result.0.downcast::<T>().unwrap();
Ok((message.deref().clone(), result.1))
Ok((*message, result.1))
}
}
}
Expand Down

0 comments on commit 2ec4797

Please sign in to comment.