renewRunLease method

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

Renews the lease for runId when owned by ownerId.

Returns true when the lease is extended, or false if ownership has changed or the run is no longer runnable.

Implementation

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