MCPcopy Create free account
hub / github.com/devflowinc/trieve / poll_task

Function poll_task

pdf2md/cli/src/operators/poll_task.rs:1–20  ·  view source on GitHub ↗
(task_id: &str, base_url: &str, api_key: &str)

Source from the content-addressed store, hash-verified

1pub fn poll_task(task_id: &str, base_url: &str, api_key: &str) {
2 loop {
3 let request = ureq::get(format!("{}/api/task/{}", base_url, task_id).as_str())
4 .set("Content-Type", "application/json")
5 .set("Authorization", api_key)
6 .call()
7 .expect("Failed to send request");
8
9 let response: serde_json::Value = request.into_json().expect("Failed to parse response");
10
11 if response["status"] == "Completed" || response["status"] == "Failed" {
12 println!("{}", response);
13 break;
14 } else {
15 println!("Task is still processing...");
16 println!("{}", response);
17 std::thread::sleep(std::time::Duration::from_secs(5));
18 }
19 }
20}

Callers 1

mainFunction · 0.85

Calls 2

callMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected