vector/sinks/elasticsearch/
health.rs1use crate::{
2 http::HttpError,
3 sinks::{elasticsearch::service::ElasticsearchResponse, util::service::HealthLogic},
4};
5
6#[derive(Clone)]
7pub struct ElasticsearchHealthLogic;
8
9impl HealthLogic for ElasticsearchHealthLogic {
10 type Error = crate::Error;
11 type Response = ElasticsearchResponse;
12
13 fn is_healthy(&self, response: &Result<Self::Response, Self::Error>) -> Option<bool> {
14 match response {
15 Ok(response) => {
16 let status = response.http_response.status();
17 if status.is_success() {
18 Some(true)
19 } else if status.is_server_error() {
20 Some(false)
21 } else {
22 None
23 }
24 }
25 Err(error) => match error.downcast_ref::<HttpError>() {
26 Some(HttpError::CallRequest { .. }) => Some(false),
27 _ => None,
28 },
29 }
30 }
31}