Skip to content

Add job heartbeat as webhook event (closes #99)#140

Merged
Josh (jbeemster) merged 1 commit intorelease/0.7.0from
feat/heartbeat-webhooks
Nov 10, 2025
Merged

Add job heartbeat as webhook event (closes #99)#140
Josh (jbeemster) merged 1 commit intorelease/0.7.0from
feat/heartbeat-webhooks

Conversation

@jbeemster
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-interval command-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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@greg-el Greg Leonard (greg-el) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Transition::Heartbeat(heartbeat_data)
);

match progress_channel.send(update) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

if let Err(e) = progress_channel.send(update) {
    warn!("Heartbeat send failed: {}, exiting", e);
    break;
}

}

// Convert to HeartbeatTaskData for the transition
let heartbeat_data: Vec<HeartbeatTaskData> = running.iter()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use into_iter and remove the clones in the .map

@jbeemster Josh (jbeemster) merged commit 7df364b into release/0.7.0 Nov 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants