Open fuyulong133 opened 5 years ago
at hargo latest version and golang at 1.10.3 , func UpdateApp() has a deadly bug,
func (e *EurekaConnection) UpdateApp(app *Application) { go func() { for { log.Noticef("Updating app %s", app.Name) err := e.readAppInto(app) if err != nil { log.Errorf("Failure updating %s in goroutine", app.Name) } <-time.After(time.Duration(e.PollInterval) * time.Second) } }() }
func (e *EurekaConnection) UpdateApp(app *Application) {
go func() {
for {
log.Noticef("Updating app %s", app.Name)
err := e.readAppInto(app)
if err != nil {
log.Errorf("Failure updating %s in goroutine", app.Name)
}
<-time.After(time.Duration(e.PollInterval) * time.Second)
}()
func NewConnFromConfig(conf Config) (c EurekaConnection) { c.ServiceUrls = conf.Eureka.ServiceUrls c.ServicePort = conf.Eureka.ServerPort if len(c.ServiceUrls) == 0 && len(conf.Eureka.ServerDNSName) > 0 { c.ServiceUrls = []string{conf.Eureka.ServerDNSName} } c.Timeout = time.Duration(conf.Eureka.ConnectTimeoutSeconds) * time.Second c.PollInterval = time.Duration(conf.Eureka.PollIntervalSeconds) * time.Second c.PreferSameZone = conf.Eureka.PreferSameZone if conf.Eureka.UseDNSForServiceUrls { log.Warning("UseDNSForServiceUrls is an experimental option") c.DNSDiscovery = true c.DiscoveryZone = conf.Eureka.DNSDiscoveryZone c.ServerURLBase = conf.Eureka.ServerURLBase } return c }
func NewConnFromConfig(conf Config) (c EurekaConnection) {
c.ServiceUrls = conf.Eureka.ServiceUrls
c.ServicePort = conf.Eureka.ServerPort
if len(c.ServiceUrls) == 0 && len(conf.Eureka.ServerDNSName) > 0 {
c.ServiceUrls = []string{conf.Eureka.ServerDNSName}
c.Timeout = time.Duration(conf.Eureka.ConnectTimeoutSeconds) * time.Second
c.PollInterval = time.Duration(conf.Eureka.PollIntervalSeconds) * time.Second
c.PreferSameZone = conf.Eureka.PreferSameZone
if conf.Eureka.UseDNSForServiceUrls {
log.Warning("UseDNSForServiceUrls is an experimental option")
c.DNSDiscovery = true
c.DiscoveryZone = conf.Eureka.DNSDiscoveryZone
c.ServerURLBase = conf.Eureka.ServerURLBase
return c
The problem is <-time.After(time.Duration(e.PollInterval) * time.Second)
s := time.Duration(3) * time.Second k := time.Duration(s) * time.Second fmt.Println(s) fmt.Println(k) ` get 3s 833333h20m0s`
s := time.Duration(3) * time.Second
k := time.Duration(s) * time.Second
fmt.Println(s)
fmt.Println(k)
`
so , they will be fixed to <-time.After(time.Duration(e.PollInterval))
at hargo latest version and golang at 1.10.3 , func UpdateApp() has a deadly bug,
func (e *EurekaConnection) UpdateApp(app *Application) {
go func() {
for {
log.Noticef("Updating app %s", app.Name)
err := e.readAppInto(app)
if err != nil {
log.Errorf("Failure updating %s in goroutine", app.Name)
}
<-time.After(time.Duration(e.PollInterval) * time.Second)
}
}()
}
func NewConnFromConfig(conf Config) (c EurekaConnection) {
c.ServiceUrls = conf.Eureka.ServiceUrls
c.ServicePort = conf.Eureka.ServerPort
if len(c.ServiceUrls) == 0 && len(conf.Eureka.ServerDNSName) > 0 {
c.ServiceUrls = []string{conf.Eureka.ServerDNSName}
}
c.Timeout = time.Duration(conf.Eureka.ConnectTimeoutSeconds) * time.Second
c.PollInterval = time.Duration(conf.Eureka.PollIntervalSeconds) * time.Second
c.PreferSameZone = conf.Eureka.PreferSameZone
if conf.Eureka.UseDNSForServiceUrls {
log.Warning("UseDNSForServiceUrls is an experimental option")
c.DNSDiscovery = true
c.DiscoveryZone = conf.Eureka.DNSDiscoveryZone
c.ServerURLBase = conf.Eureka.ServerURLBase
}
return c
}
The problem is <-time.After(time.Duration(e.PollInterval) * time.Second)
s := time.Duration(3) * time.Second
k := time.Duration(s) * time.Second
fmt.Println(s)
fmt.Println(k)
`
getso , they will be fixed to <-time.After(time.Duration(e.PollInterval))