custom start test fn
This commit is contained in:
parent
669b2da871
commit
537c3565a2
2 changed files with 25 additions and 24 deletions
|
@ -620,10 +620,10 @@ pub struct Routine {
|
||||||
pub module : BotModule , // from() can determine this if passed parents_params
|
pub module : BotModule , // from() can determine this if passed parents_params
|
||||||
pub channel : Channel , // Requiring some channel context
|
pub channel : Channel , // Requiring some channel context
|
||||||
exec_body: bot_actions::actions_util::ExecBody,
|
exec_body: bot_actions::actions_util::ExecBody,
|
||||||
parent_params : ExecBodyParams ,
|
pub parent_params : ExecBodyParams ,
|
||||||
pub join_handle : Option<Arc<RwLock<JoinHandle<RoutineAR>>>> ,
|
pub join_handle : Option<Arc<RwLock<JoinHandle<RoutineAR>>>> ,
|
||||||
start_time : Option<DateTime<Local>> ,
|
start_time : Option<DateTime<Local>> ,
|
||||||
complete_iterations : i64 ,
|
pub complete_iterations : i64 ,
|
||||||
remaining_iterations : Option<i64> ,
|
remaining_iterations : Option<i64> ,
|
||||||
routine_attr : Vec<RoutineAttr> ,
|
routine_attr : Vec<RoutineAttr> ,
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,19 +89,6 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
|
|
||||||
async fn rtestbody(params : ExecBodyParams) {
|
async fn rtestbody(params : ExecBodyParams) {
|
||||||
|
|
||||||
// let bot = Arc::clone(¶ms.bot);
|
|
||||||
|
|
||||||
// let botlock = bot.read().await;
|
|
||||||
|
|
||||||
// // uses chat.say_in_reply_to() for the bot controls for messages
|
|
||||||
// botlock
|
|
||||||
// .botmgrs
|
|
||||||
// .chat
|
|
||||||
// .say_in_reply_to(
|
|
||||||
// ¶ms.msg.clone(),
|
|
||||||
// String::from("Inner Routine Loop Message"),
|
|
||||||
// params.clone()
|
|
||||||
// ).await;
|
|
||||||
|
|
||||||
let logmsg_botact = match *params.curr_act.read().await {
|
let logmsg_botact = match *params.curr_act.read().await {
|
||||||
BotAction::C(_) => "command",
|
BotAction::C(_) => "command",
|
||||||
|
@ -110,19 +97,26 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
botlog::trace(
|
botlog::trace(
|
||||||
// format!("Params > Curr_act : {:?}", params.curr_act).as_str(), // BotAction doesn't imblement debug
|
|
||||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||||
Some("Experiments003 > test3 command body".to_string()),
|
Some("Experiments003 > test3 command body".to_string()),
|
||||||
Some(¶ms.msg),
|
Some(¶ms.msg),
|
||||||
);
|
);
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
|
||||||
for _ in 0..5 {
|
if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||||
println!("tester");
|
for curriter in 0..5 {
|
||||||
|
println!("tester - Routine - Completed Iterations : {}",
|
||||||
|
arr.read().await.complete_iterations);
|
||||||
|
println!("tester - Custom Loop - Completed Iterations : {}",
|
||||||
|
curriter);
|
||||||
sleep(Duration::from_secs_f64(0.5)).await;
|
sleep(Duration::from_secs_f64(0.5)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
botlog::debug(
|
botlog::debug(
|
||||||
format!("RTESTBODY : module - {:?} ; channel - {:?}",
|
format!("RTESTBODY : module - {:?} ; channel - {:?}",
|
||||||
|
@ -149,7 +143,8 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
|
|
||||||
// [ ] before execute , be sure to adjust curr_act
|
// [ ] before execute , be sure to adjust curr_act
|
||||||
|
|
||||||
let mut params_mut = params.clone();
|
// let mut params_mut = params.clone();
|
||||||
|
let mut params_mut = params;
|
||||||
// let newr_ar = Arc::new(RwLock::new(newr));
|
// let newr_ar = Arc::new(RwLock::new(newr));
|
||||||
let newr_ar = newr.clone();
|
let newr_ar = newr.clone();
|
||||||
|
|
||||||
|
@ -163,6 +158,12 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
// let mut newr_lock = newr_ar.write().await;
|
// let mut newr_lock = newr_ar.write().await;
|
||||||
|
|
||||||
// let rslt = newr_ar.write().await.start().await;
|
// let rslt = newr_ar.write().await.start().await;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
newr_ar.write().await.parent_params = params_mut.clone();
|
||||||
|
}
|
||||||
|
|
||||||
let rslt = Routine::start(newr_ar.clone()).await;
|
let rslt = Routine::start(newr_ar.clone()).await;
|
||||||
|
|
||||||
// let rslt = newr_ar.read().await.start().await;
|
// let rslt = newr_ar.read().await.start().await;
|
||||||
|
@ -178,12 +179,12 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
rsltstr
|
rsltstr
|
||||||
).as_str(),
|
).as_str(),
|
||||||
Some("experiment003 > test3_body".to_string()),
|
Some("experiment003 > test3_body".to_string()),
|
||||||
Some(¶ms.msg),
|
Some(¶ms_mut.msg),
|
||||||
);
|
);
|
||||||
|
|
||||||
Log::flush();
|
Log::flush();
|
||||||
|
|
||||||
let bot = Arc::clone(¶ms.bot);
|
let bot = Arc::clone(¶ms_mut.bot);
|
||||||
|
|
||||||
let botlock = bot.read().await;
|
let botlock = bot.read().await;
|
||||||
|
|
||||||
|
@ -192,9 +193,9 @@ async fn test3_body(params : ExecBodyParams) {
|
||||||
.botmgrs
|
.botmgrs
|
||||||
.chat
|
.chat
|
||||||
.say_in_reply_to(
|
.say_in_reply_to(
|
||||||
¶ms.msg,
|
¶ms_mut.msg,
|
||||||
format!("Routine Result : {:?}",rsltstr),
|
format!("Routine Result : {:?}",rsltstr),
|
||||||
params.clone()
|
params_mut.clone()
|
||||||
).await;
|
).await;
|
||||||
|
|
||||||
// [x] Will not be handling JoinHandles here . If immediate abort() handling is required, below is an example that works
|
// [x] Will not be handling JoinHandles here . If immediate abort() handling is required, below is an example that works
|
||||||
|
|
Loading…
Reference in a new issue