Use ReadTimeout*0.8 as max heartBeatTimeout rather than ReadTimeout/2.
Heartbeat is usually returned very quickly, no need to force two heartbeat within one read timeout period. User can change the configuration to bring back the setting if needed.
This commit is contained in:
@@ -79,10 +79,11 @@ func (s Server) WithDefault() Server {
|
|||||||
readTimeout := s.maxDur(initialTimeout, 3*time.Second)
|
readTimeout := s.maxDur(initialTimeout, 3*time.Second)
|
||||||
readTimeout = s.maxDur(s.ReadTimeout, readTimeout)
|
readTimeout = s.maxDur(s.ReadTimeout, readTimeout)
|
||||||
|
|
||||||
heartBeatTimeout := s.minDur(s.HeartbeatTimeout, readTimeout/2)
|
maxHeartBeatTimeout := time.Duration(float64(readTimeout) * 0.8)
|
||||||
|
heartBeatTimeout := s.minDur(s.HeartbeatTimeout, maxHeartBeatTimeout)
|
||||||
|
|
||||||
if heartBeatTimeout <= 0 {
|
if heartBeatTimeout <= 0 {
|
||||||
heartBeatTimeout = readTimeout / 2
|
heartBeatTimeout = maxHeartBeatTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
return Server{
|
return Server{
|
||||||
|
|||||||
Reference in New Issue
Block a user