From 1757aa7e337c7b4e0a725bb73c04d3678a82789e Mon Sep 17 00:00:00 2001 From: vicanso Date: Fri, 27 Dec 2024 20:59:20 +0800 Subject: [PATCH] refactor: adjust grpc health check --- README.md | 2 +- README_zh.md | 2 +- src/health/mod.rs | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c7129e..fc9540e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ flowchart LR - Configuration based on TOML format, the configuration is very simple, and can be saved to files or etcd - Supports more than 10 Prometheus indicators, pull and push mode - Opentelemetry supports w3c context trace and jaeger trace -- Frequently updated config: upstream, location and plugin, which adjustments take effect in 10 seconds, and other config is updated, program will be restarted gracefully without interruption +- All configurations except server configuration support hot reload, which adjustments take effect in 10 seconds. The service configuration takes effect after the application is restarted - Templated configuration of access logs, which supports more than 30 related attribute configurations, and various parameters and indicators can be specified as needed - Web UI for config, simple and easy to use - Support let's encrypt, just set the domain of http server diff --git a/README_zh.md b/README_zh.md index 83a5928..6ea12be 100644 --- a/README_zh.md +++ b/README_zh.md @@ -27,7 +27,7 @@ flowchart LR - 基于TOML格式的配置,配置方式非常简洁,可保存至文件或etcd - 支持10多个Prometheus指标,可以使用pull与push的形式收集相关指标 - Opentelemetry支持w3c context trace与jaeger trace的形式 -- 频繁更新的Upstream、Location以及Plugin相关配置调整准实时生效(10秒)且无任何中断请求,其它应用配置更新后,无中断式的优雅重启程序 +- 除server的配置外,所有的配置均支持热更新(10秒内)且无任何中断请求,服务配置在应用重启后生效 - 访问日志的模板化配置,已支30多个相关属性的配置,可按需指定输出各种参数与指标 - WEB形式的管理后台界面,无需学习,简单易用 - 开箱即用的let's encrypttls证书,仅需配置对应域名即可,可在单一配置中使用多个子域名 diff --git a/src/health/mod.rs b/src/health/mod.rs index 89b0185..e382437 100644 --- a/src/health/mod.rs +++ b/src/health/mod.rs @@ -50,6 +50,8 @@ fn update_peer_options( ) -> PeerOptions { let mut options = opt; let timeout = Some(conf.connection_timeout); + options.verify_hostname = false; + options.verify_cert = false; options.connection_timeout = timeout; options.total_connection_timeout = timeout; options.read_timeout = Some(conf.read_timeout); @@ -261,6 +263,7 @@ pub struct GrpcHealthCheck { pub consecutive_failure: usize, /// A callback that is invoked when the `healthy` status changes for a [Backend]. pub health_changed_callback: Option, + pub connection_timeout: Duration, } impl GrpcHealthCheck { @@ -279,6 +282,7 @@ impl GrpcHealthCheck { service: conf.service.clone(), consecutive_success: conf.consecutive_success, consecutive_failure: conf.consecutive_failure, + connection_timeout: conf.connection_timeout, health_changed_callback: Some( webhook::new_backend_observe_notification(name), ), @@ -294,6 +298,7 @@ impl HealthCheck for GrpcHealthCheck { let conn = tonic::transport::Endpoint::from_shared(uri) .map_err(|e| util::new_internal_error(500, e.to_string()))? .origin(self.origin.clone()) + .connect_timeout(self.connection_timeout) .connect() .await .map_err(|e| util::new_internal_error(500, e.to_string()))?;