Skip to content

Commit

Permalink
Merge pull request #1007 from MI-cool/MI-cool-patch-1
Browse files Browse the repository at this point in the history
调整leaseInfo为nil时的心跳参数处理逻辑与eureka server一致
  • Loading branch information
andrewshan authored Mar 15, 2023
2 parents a0420f6 + 6fe29e7 commit 9bcda11
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions apiserver/eurekaserver/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,18 @@ func buildBaseInstance(instance *InstanceInfo, namespace string, appId string) *

func buildHealthCheck(instance *InstanceInfo, targetInstance *apiservice.Instance, eurekaMetadata map[string]string) {
leaseInfo := instance.LeaseInfo
var durationInSecs int
var renewalIntervalInSecs int
durationInSecs := DefaultDuration
renewalIntervalInSecs := DefaultRenewInterval
if leaseInfo != nil {
renewalIntervalInSecs = leaseInfo.RenewalIntervalInSecs
durationInSecs = leaseInfo.DurationInSecs
if renewalIntervalInSecs == 0 {
renewalIntervalInSecs = DefaultRenewInterval
if leaseInfo.RenewalIntervalInSecs != 0 {
renewalIntervalInSecs = leaseInfo.RenewalIntervalInSecs
}
if durationInSecs == 0 {
durationInSecs = DefaultDuration
}
if renewalIntervalInSecs != DefaultRenewInterval {
eurekaMetadata[MetadataRenewalInterval] = strconv.Itoa(renewalIntervalInSecs)
}
if durationInSecs != DefaultDuration {
eurekaMetadata[MetadataDuration] = strconv.Itoa(durationInSecs)
if leaseInfo.DurationInSecs != 0 {
durationInSecs = leaseInfo.DurationInSecs
}
}
eurekaMetadata[MetadataRenewalInterval] = strconv.Itoa(renewalIntervalInSecs)
eurekaMetadata[MetadataDuration] = strconv.Itoa(durationInSecs)
durationMin := math.Ceil(float64(durationInSecs) / 3)
ttl := uint32(math.Min(durationMin, float64(renewalIntervalInSecs)))

Expand Down

0 comments on commit 9bcda11

Please sign in to comment.