@@ -31,27 +31,33 @@ UdpHealthChecker::UdpHealthChecker() { timeout_ms_ = 0; }
3131UdpHealthChecker::~UdpHealthChecker () {}
3232
3333ReturnCode UdpHealthChecker::Init (Config* config, Context* /* context*/ ) {
34- std::string send_package = config->GetStringOrDefault (
35- HealthCheckerConfig::kUdpSendPackageKey , HealthCheckerConfig::kUdpSendPackageDefault );
34+ static const char kUdpSendPackageKey [] = " send" ;
35+ static const char kUdpSendPackageDefault [] = " " ;
36+ static const char kUdpReceivePackageKey [] = " receive" ;
37+ static const char kUdpReceivePackageDefault [] = " " ;
38+
39+ std::string send_package = config->GetStringOrDefault (kUdpSendPackageKey , kUdpSendPackageDefault );
3640 if (send_package.empty ()) {
37- POLARIS_LOG (LOG_ERROR, " health checker [%s] config %s should not be empty" ,
38- kPluginUdpHealthChecker , HealthCheckerConfig:: kUdpSendPackageKey );
41+ POLARIS_LOG (LOG_ERROR, " outlier detector [%s] config %s should not be empty" ,
42+ kPluginUdpHealthChecker , kUdpSendPackageKey );
3943 return kReturnInvalidConfig ;
4044 }
4145 if (!Utils::HexStringToBytes (send_package, &send_package_)) {
42- POLARIS_LOG (LOG_ERROR, " health checker[%s] config %s hexstring to bytes failed" ,
43- kPluginUdpHealthChecker , HealthCheckerConfig::kUdpSendPackageKey );
46+ POLARIS_LOG (LOG_ERROR, " outlier detector[%s] config %s hexstring to bytes failed" ,
47+ kPluginUdpHealthChecker , kUdpSendPackageKey );
48+ return kReturnInvalidConfig ;
4449 }
45- std::string receive_package = config-> GetStringOrDefault (
46- HealthCheckerConfig:: kUdpReceivePackageKey , HealthCheckerConfig:: kUdpReceivePackageDefault );
50+ std::string receive_package =
51+ config-> GetStringOrDefault ( kUdpReceivePackageKey , kUdpReceivePackageDefault );
4752 if (!receive_package.empty ()) {
4853 if (!Utils::HexStringToBytes (receive_package, &receive_package_)) {
49- POLARIS_LOG (LOG_ERROR, " health checker[%s] config %s hexstring to bytes failed" ,
50- kPluginUdpHealthChecker , HealthCheckerConfig::kUdpReceivePackageKey );
54+ POLARIS_LOG (LOG_ERROR, " outlier detector[%s] config %s hexstring to bytes failed" ,
55+ kPluginUdpHealthChecker , kUdpReceivePackageKey );
56+ return kReturnInvalidConfig ;
5157 }
5258 }
53- timeout_ms_ = config->GetIntOrDefault (HealthCheckerConfig::kTimeoutKey ,
54- HealthCheckerConfig::kTimeoutDefault );
59+ timeout_ms_ = config->GetMsOrDefault (HealthCheckerConfig ::kTimeoutKey ,
60+ HealthCheckerConfig::kTimeoutDefault );
5561 return kReturnOk ;
5662}
5763
0 commit comments