Skip to content

Commit

Permalink
Remove unnecessary Arc/Mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
ramosbugs committed Dec 3, 2023
1 parent c0e6b36 commit df44db4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions examples/extension-internal-flush/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use std::sync::Arc;

/// Implements an internal Lambda extension to flush logs/telemetry after each request.
struct FlushExtension {
request_done_receiver: Arc<Mutex<UnboundedReceiver<()>>>,
request_done_receiver: Mutex<UnboundedReceiver<()>>,
}

impl FlushExtension {
pub fn new(request_done_receiver: UnboundedReceiver<()>) -> Self {
Self {
request_done_receiver: Arc::new(Mutex::new(request_done_receiver)),
request_done_receiver: Mutex::new(request_done_receiver),
}
}

Expand Down Expand Up @@ -55,14 +55,12 @@ struct Data {

/// Implements the main event handler for processing events from an SQS queue.
struct EventHandler {
request_done_sender: Arc<Mutex<UnboundedSender<()>>>,
request_done_sender: UnboundedSender<()>,
}

impl EventHandler {
pub fn new(request_done_sender: UnboundedSender<()>) -> Self {
Self {
request_done_sender: Arc::new(Mutex::new(request_done_sender)),
}
Self { request_done_sender }
}

pub async fn invoke(
Expand All @@ -75,7 +73,7 @@ impl EventHandler {
// <process event here>

// Notify the extension to flush traces.
self.request_done_sender.lock().await.send(()).map_err(Box::new)?;
self.request_done_sender.send(()).map_err(Box::new)?;

Ok(SqsBatchResponse::default())
}
Expand Down

0 comments on commit df44db4

Please sign in to comment.