@@ -12,13 +12,6 @@ use vbare::OwnedVersionedData;
1212
1313use crate :: { keys, metrics, workflows:: actor:: Allocate } ;
1414
15- /// How long after last ping before considering a runner ineligible for allocation.
16- pub const RUNNER_ELIGIBLE_THRESHOLD_MS : i64 = util:: duration:: seconds ( 10 ) ;
17- /// How long to wait after last ping before forcibly removing a runner from the database and deleting its
18- /// workflow, evicting all actors. Note that the runner may still be running and can reconnect.
19- ///
20- /// Runner ping interval is currently set to 3s.
21- const RUNNER_LOST_THRESHOLD_MS : i64 = util:: duration:: seconds ( 15 ) ;
2215/// Batch size of how many events to ack.
2316const EVENT_ACK_BATCH_SIZE : i64 = 500 ;
2417
@@ -88,8 +81,10 @@ pub async fn pegboard_runner(ctx: &mut WorkflowCtx, input: &Input) -> Result<()>
8881 let input = input. clone ( ) ;
8982
9083 async move {
84+ let runner_lost_threshold = ctx. config ( ) . pegboard ( ) . runner_lost_threshold ( ) ;
85+
9186 match ctx
92- . listen_with_timeout :: < Main > ( RUNNER_LOST_THRESHOLD_MS )
87+ . listen_with_timeout :: < Main > ( runner_lost_threshold )
9388 . await ?
9489 {
9590 Some ( Main :: Forward ( sig) ) => {
@@ -117,7 +112,7 @@ pub async fn pegboard_runner(ctx: &mut WorkflowCtx, input: &Input) -> Result<()>
117112 runner_id : input. runner_id . to_string ( ) ,
118113 last_event_idx : init_data. last_event_idx ,
119114 metadata : protocol:: ProtocolMetadata {
120- runner_lost_threshold : RUNNER_LOST_THRESHOLD_MS ,
115+ runner_lost_threshold : runner_lost_threshold ,
121116 } ,
122117 } ) ,
123118 } )
@@ -403,7 +398,7 @@ async fn handle_stopping(
403398) -> Result < ( ) > {
404399 if !state. draining {
405400 // The workflow will enter a draining state where it can still process signals if
406- // needed. After RUNNER_LOST_THRESHOLD_MS it will exit this loop and stop.
401+ // needed. After the runner lost threshold it will exit this loop and stop.
407402 state. draining = true ;
408403
409404 // Can't parallelize these two activities, requires reading from state
@@ -942,6 +937,8 @@ struct CheckExpiredInput {
942937
943938#[ activity( CheckExpired ) ]
944939async fn check_expired ( ctx : & ActivityCtx , input : & CheckExpiredInput ) -> Result < bool > {
940+ let runner_lost_threshold = ctx. config ( ) . pegboard ( ) . runner_lost_threshold ( ) ;
941+
945942 ctx. udb ( ) ?
946943 . run ( |tx| async move {
947944 let tx = tx. with_subspace ( keys:: subspace ( ) ) ;
@@ -954,7 +951,7 @@ async fn check_expired(ctx: &ActivityCtx, input: &CheckExpiredInput) -> Result<b
954951 . await ?;
955952
956953 let now = util:: timestamp:: now ( ) ;
957- let expired = last_ping_ts < now - RUNNER_LOST_THRESHOLD_MS ;
954+ let expired = last_ping_ts < now - runner_lost_threshold ;
958955
959956 if expired {
960957 tx. write ( & keys:: runner:: ExpiredTsKey :: new ( input. runner_id ) , now) ?;
@@ -989,6 +986,8 @@ pub(crate) async fn allocate_pending_actors(
989986 ctx : & ActivityCtx ,
990987 input : & AllocatePendingActorsInput ,
991988) -> Result < AllocatePendingActorsOutput > {
989+ let runner_eligible_threshold = ctx. config ( ) . pegboard ( ) . runner_eligible_threshold ( ) ;
990+
992991 // NOTE: This txn should closely resemble the one found in the allocate_actor activity of the actor wf
993992 let ( allocations, pending_actor_count) = ctx
994993 . udb ( ) ?
@@ -1012,7 +1011,7 @@ pub(crate) async fn allocate_pending_actors(
10121011 Snapshot ,
10131012 ) ;
10141013 let mut pending_actor_count = 0 ;
1015- let ping_threshold_ts = util:: timestamp:: now ( ) - RUNNER_ELIGIBLE_THRESHOLD_MS ;
1014+ let ping_threshold_ts = util:: timestamp:: now ( ) - runner_eligible_threshold ;
10161015
10171016 ' queue_loop: loop {
10181017 let Some ( queue_entry) = queue_stream. try_next ( ) . await ? else {
0 commit comments