Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/services/pegboard/src/workflows/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub const RUNNER_ELIGIBLE_THRESHOLD_MS: i64 = util::duration::seconds(10);
/// How long to wait after last ping before forcibly removing a runner from the database and deleting its
/// workflow, evicting all actors. Note that the runner may still be running and can reconnect.
const RUNNER_LOST_THRESHOLD_MS: i64 = util::duration::minutes(2);
/// Batch size of how many events to ack.
const EVENT_ACK_BATCH_SIZE: i64 = 500;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Input {
Expand Down Expand Up @@ -199,8 +201,12 @@ pub async fn pegboard_runner(ctx: &mut WorkflowCtx, input: &Input) -> Result<()>

state.last_event_idx = last_event_idx;

// Ack every 500 events
if last_event_idx > state.last_event_ack_idx.saturating_add(500) {
// Ack events in batch
if last_event_idx
> state
.last_event_ack_idx
.saturating_add(EVENT_ACK_BATCH_SIZE)
{
state.last_event_ack_idx = last_event_idx;

ctx.activity(SendMessageToRunnerInput {
Expand Down
106 changes: 54 additions & 52 deletions sdks/typescript/runner/src/mod.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading