(config: SSHConnectionConfig, errorMessage: string)
| 358 | } |
| 359 | |
| 360 | reportFailure(config: SSHConnectionConfig, errorMessage: string): void { |
| 361 | const key = makeConnectionKey(config); |
| 362 | const now = new Date(); |
| 363 | const current = this.health.get(key); |
| 364 | const failures = (current?.consecutiveFailures ?? 0) + 1; |
| 365 | const backoffIndex = Math.min(failures - 1, SSH_BACKOFF_SCHEDULE_SECONDS.length - 1); |
| 366 | const backoffSeconds = withSshBackoffJitter(SSH_BACKOFF_SCHEDULE_SECONDS[backoffIndex]); |
| 367 | |
| 368 | this.health.set(key, { |
| 369 | status: "unhealthy", |
| 370 | lastFailure: now, |
| 371 | lastError: errorMessage, |
| 372 | consecutiveFailures: failures, |
| 373 | backoffUntil: new Date(Date.now() + backoffSeconds * 1000), |
| 374 | lastSuccess: current?.lastSuccess, |
| 375 | }); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Clear all health state. Used in tests to reset between test cases |
no test coverage detected