renewRunExecution method

  1. @override
Future<bool> renewRunExecution(
  1. String runId, {
  2. required String executionId,
  3. Duration leaseDuration = const Duration(seconds: 30),
})
override

Renews a still-active, unexpired lease only when executionId is current.

Implementation

@override
Future<bool> renewRunExecution(
  String runId, {
  required String executionId,
  Duration leaseDuration = const Duration(seconds: 30),
}) async {
  final state = _runs[runId];
  if (state == null ||
      state.status != WorkflowStatus.running ||
      state.executionId != executionId) {
    return false;
  }
  final now = _clock.now();
  if (state.ownerId == null || _leaseExpired(state, now)) return false;
  _runs[runId] = state.copyWith(
    leaseExpiresAt: now.add(leaseDuration),
    updatedAt: now,
  );
  return true;
}