Add job heartbeat as webhook event (closes #99)#140
Add job heartbeat as webhook event (closes #99)#140Josh (jbeemster) merged 1 commit intorelease/0.7.0from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a heartbeat mechanism for long-running tasks, allowing periodic task updates with cumulative logs to be sent via webhooks during task execution. The feature is controlled by a new command-line option --heartbeat-interval=<seconds>.
Key changes:
- Adds
--heartbeat-intervalcommand-line flag to specify periodic update frequency - Implements heartbeat module to track running tasks and collect cumulative stdout/stderr logs
- Extends webhook updates to include live task logs from running tasks
- Updates execution strategy to support streaming log buffers for heartbeat functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds CLI flag and threads the heartbeat interval parameter through execution functions |
| src/factotum/executor/mod.rs | Integrates heartbeat thread lifecycle, manages shared task snapshots, and registers/unregisters running tasks |
| src/factotum/executor/heartbeat.rs | New module implementing heartbeat thread, task state tracking, and log buffer management |
| src/factotum/executor/execution_strategy/mod.rs | Adds buffer support to execution strategy for capturing stdout/stderr in real-time |
| src/factotum/webhook/jobupdate/mod.rs | Updates webhook job update to include heartbeat transitions and live task logs |
| samples/test-heartbeat.factfile | New sample file for testing heartbeat functionality |
| samples/concurrent-streaming-output.factfile | Modified test to extend task duration for heartbeat testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c203e9d to
86536a9
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
86536a9 to
332d349
Compare
Greg Leonard (greg-el)
left a comment
There was a problem hiding this comment.
Looks good! Some clones you can avoid, but otherwise 🚢
| if let Ok(line) = line { | ||
| println!("[{}] {}", name_stdout.cyan(), line); | ||
| lines.push(line); | ||
| lines.push(line.clone()); |
There was a problem hiding this comment.
You can avoid this clone if you move this to after the next block (102-108)
| if let Ok(line) = line { | ||
| eprintln!("[{}] {}", name_stderr.cyan(), line.red()); | ||
| lines.push(line); | ||
| lines.push(line.clone()); |
src/factotum/executor/heartbeat.rs
Outdated
| Transition::Heartbeat(heartbeat_data) | ||
| ); | ||
|
|
||
| match progress_channel.send(update) { |
There was a problem hiding this comment.
nit:
if let Err(e) = progress_channel.send(update) {
warn!("Heartbeat send failed: {}, exiting", e);
break;
}
src/factotum/executor/heartbeat.rs
Outdated
| } | ||
|
|
||
| // Convert to HeartbeatTaskData for the transition | ||
| let heartbeat_data: Vec<HeartbeatTaskData> = running.iter() |
There was a problem hiding this comment.
nit: use into_iter and remove the clones in the .map
332d349 to
c820712
Compare
No description provided.