* Write a marker field under the monotonic guard, refreshing the key TTL. The * TTL is a backstop for executions that die without a terminal/pause boundary * (deterministic cleanup is clearProgressMarkers); it mirrors the * admission-reservation TTL so a crashed run's marker key and slot
( executionId: string, field: string, timestampField: 'startedAt' | 'endedAt', timestamp: string, marker: ExecutionLastStartedBlock | ExecutionLastCompletedBlock )
| 65 | * so callers can fall back to the SQL path on a missing client or a failure. |
| 66 | */ |
| 67 | async function setMarker( |
| 68 | executionId: string, |
| 69 | field: string, |
| 70 | timestampField: 'startedAt' | 'endedAt', |
| 71 | timestamp: string, |
| 72 | marker: ExecutionLastStartedBlock | ExecutionLastCompletedBlock |
| 73 | ): Promise<boolean> { |
| 74 | const redis = getMarkerClient() |
| 75 | if (!redis) return false |
| 76 | |
| 77 | try { |
| 78 | await redis.eval( |
| 79 | SET_MARKER_SCRIPT, |
| 80 | 1, |
| 81 | markerKey(executionId), |
| 82 | field, |
| 83 | timestampField, |
| 84 | timestamp, |
| 85 | JSON.stringify(marker), |
| 86 | getExecutionReservationTtlMs().toString() |
| 87 | ) |
| 88 | return true |
| 89 | } catch (error) { |
| 90 | logger.error(`Failed to persist progress marker for execution ${executionId}`, { |
| 91 | field, |
| 92 | error: toError(error).message, |
| 93 | }) |
| 94 | return false |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Persist the last-started-block marker. Returns `false` (caller should fall |
no test coverage detected