| 113 | } |
| 114 | |
| 115 | fn render_database(state: &HealthState) -> DependencyCheck { |
| 116 | match state { |
| 117 | HealthState::Initializing => DependencyCheck { |
| 118 | status: STATUS_UNHEALTHY, |
| 119 | latency_ms: None, |
| 120 | error: Some(DATABASE_INITIALIZING_ERROR.to_string()), |
| 121 | }, |
| 122 | HealthState::Healthy { latency_ms } => DependencyCheck { |
| 123 | status: STATUS_HEALTHY, |
| 124 | latency_ms: Some(*latency_ms), |
| 125 | error: None, |
| 126 | }, |
| 127 | HealthState::Unhealthy(HealthError::Unavailable { latency_ms }) => DependencyCheck { |
| 128 | status: STATUS_UNHEALTHY, |
| 129 | latency_ms: Some(*latency_ms), |
| 130 | error: Some(DATABASE_UNAVAILABLE_ERROR.to_string()), |
| 131 | }, |
| 132 | HealthState::Unhealthy(HealthError::Timeout) => DependencyCheck { |
| 133 | status: STATUS_UNHEALTHY, |
| 134 | latency_ms: None, |
| 135 | error: Some(DATABASE_TIMEOUT_ERROR.to_string()), |
| 136 | }, |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /// Build the health router by spawning a background [`DatabaseHealthMonitor`] |
| 141 | /// for `store` and wiring its receiver into the handlers. |