rsiot/components/cmp_create_if_not_exist/
fn_process.rs1use std::time::Duration;
2
3use tokio::time::sleep;
4
5use crate::{executor::CmpInOut, message::MsgDataBound};
6
7use super::Config;
8
9pub async fn fn_process<TMsg>(config: Config<TMsg>, msg_bus: CmpInOut<TMsg>) -> super::Result<()>
10where
11 TMsg: MsgDataBound,
12{
13 sleep(config.delay).await;
14
15 let mut msgs = vec![];
16
17 let cache = msg_bus.cache.read().await;
18 for msg in config.msgs {
19 if cache.contains_key(&msg.key) {
20 continue;
21 }
22 msgs.push(msg);
23 }
24 drop(cache);
25
26 sleep(Duration::MAX).await;
27 Ok(())
28}