pub mod issue_delivery_worker;
pub use issue_delivery_worker::*;
use std::collections::HashMap;
use std::str::FromStr;
use strum_macros::EnumString;
#[derive(Debug, EnumString)]
pub enum TaskNames {
Task1,
Task2,
GetIp,
}
pub fn task1() {
log::info!("task1");
}
pub fn task2() {
log::info!("task2");
}
pub fn getip() {
tokio::runtime::Runtime::new().unwrap().block_on(async {
let resp = reqwest::get("https://httpbin.org/ip")
.await
.unwrap()
.json::<HashMap<String, String>>()
.await
.unwrap();
log::info!("ip={:?}", resp);
});
}
pub async fn execute_task(function_name: &str, expression: &str) {
if let Ok(function_enum) = TaskNames::from_str(function_name) {
match function_enum {
TaskNames::Task1 => {
crate::core::looop::running(expression, 100, task1).await;
}
TaskNames::Task2 => {
crate::core::looop::running(expression, 100, task2).await;
}
TaskNames::GetIp => {
crate::core::looop::running(expression, 100, getip).await;
}
}
}
}