Skip to content

Commit

Permalink
change discard to forward
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Aug 22, 2024
1 parent 1a3f9fe commit cc8a37d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions atoma-event-subscribe/sui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::time::Duration;

use atoma_sui::subscriber::{SuiSubscriber, SuiSubscriberError};
use atoma_types::InputSource;
use clap::Parser;
use sui_sdk::types::base_types::ObjectID;
use tokio::sync::oneshot;
use tracing::{error, info};

#[derive(Debug, Parser)]
Expand All @@ -28,12 +30,20 @@ async fn main() -> Result<(), SuiSubscriberError> {
let ws_url = args.ws_addr;

let (event_sender, mut event_receiver) = tokio::sync::mpsc::channel(32);
let (input_manager_tx, mut input_manager_rx) = tokio::sync::mpsc::channel(32);
let (input_manager_tx, mut input_manager_rx) =
tokio::sync::mpsc::channel::<(InputSource, oneshot::Sender<String>)>(32);

// Spawn a task to discard messages
tokio::spawn(async move {
while let Some(_msg) = input_manager_rx.recv().await {
// Discard the message
while let Some((input_source, oneshot)) = input_manager_rx.recv().await {
info!("Received input from source: {:?}", input_source);
let data = match input_source {
InputSource::Firebase { request_id } => request_id,
InputSource::Raw { prompt } => prompt,
};
if let Err(err) = oneshot.send(data) {
error!("Failed to send response: {:?}", err);
}
}
});

Expand Down

0 comments on commit cc8a37d

Please sign in to comment.