Runs initial health check and evaluate healthiness based on initial_health_check_policy.
(self)
| 368 | return db_results |
| 369 | |
| 370 | async def _perform_initial_health_check(self): |
| 371 | """ |
| 372 | Runs initial health check and evaluate healthiness based on initial_health_check_policy. |
| 373 | """ |
| 374 | results = await self._check_databases_health() |
| 375 | is_healthy = True |
| 376 | |
| 377 | if self._config.initial_health_check_policy == InitialHealthCheck.ALL_AVAILABLE: |
| 378 | is_healthy = False not in results.values() |
| 379 | elif ( |
| 380 | self._config.initial_health_check_policy |
| 381 | == InitialHealthCheck.MAJORITY_AVAILABLE |
| 382 | ): |
| 383 | is_healthy = sum(results.values()) > len(results) / 2 |
| 384 | elif ( |
| 385 | self._config.initial_health_check_policy == InitialHealthCheck.ONE_AVAILABLE |
| 386 | ): |
| 387 | is_healthy = True in results.values() |
| 388 | |
| 389 | if not is_healthy: |
| 390 | raise InitialHealthCheckFailedError( |
| 391 | f"Initial health check failed. Initial health check policy: {self._config.initial_health_check_policy}" |
| 392 | ) |
| 393 | |
| 394 | def _on_circuit_state_change_callback( |
| 395 | self, circuit: CircuitBreaker, old_state: CBState, new_state: CBState |
nothing calls this directly
no test coverage detected