move dsl's to rhailib
This commit is contained in:
@@ -78,46 +78,6 @@ fn create_batch_tasks(task_count: usize) -> Result<Vec<String>, Box<dyn std::err
|
||||
Ok(task_keys)
|
||||
}
|
||||
|
||||
fn wait_and_measure(task_key: &str) -> Result<f64, redis::RedisError> {
|
||||
let client = Client::open(REDIS_URL)?;
|
||||
let mut conn = client.get_connection()?;
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
let timeout = Duration::from_secs(100);
|
||||
|
||||
// Poll until task is completed or timeout
|
||||
loop {
|
||||
let status: Option<String> = conn.hget(task_key, "status")?;
|
||||
|
||||
match status.as_deref() {
|
||||
Some("completed") | Some("error") => {
|
||||
println!(
|
||||
"Task {} completed with status: {}",
|
||||
task_key,
|
||||
status.as_deref().unwrap_or("unknown")
|
||||
);
|
||||
let created_at: u64 = conn.hget(task_key, "createdAt")?;
|
||||
let updated_at: u64 = conn.hget(task_key, "updatedAt")?;
|
||||
return Ok((updated_at - created_at) as f64 * 1000.0); // Convert to milliseconds
|
||||
}
|
||||
Some("pending") | Some("processing") => {
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
_ => {
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
|
||||
// Check timeout
|
||||
if start_time.elapsed() > timeout {
|
||||
return Err(redis::RedisError::from((
|
||||
redis::ErrorKind::IoError,
|
||||
"Timeout waiting for task completion",
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn wait_for_batch_completion(task_keys: &[String]) -> Result<f64, Box<dyn std::error::Error>> {
|
||||
let client = Client::open(REDIS_URL)?;
|
||||
let mut conn = client.get_connection()?;
|
||||
|
Reference in New Issue
Block a user