1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-19 21:18:07 +02:00

fix registerttl = timer*3

This commit is contained in:
LibiChai 2019-07-22 13:42:08 +08:00
parent 22e7564832
commit 91abcf2590

View File

@ -25,7 +25,7 @@ var (
etcdPrefix string etcdPrefix string
//Time units is second //Time units is second
registerTTL = 30 registerTTL = 90
defaultDialTimeout = 30 defaultDialTimeout = 30
) )
@ -183,8 +183,8 @@ func (e *EtcdBuilder) Register(ctx context.Context, ins *naming.Instance) (cance
}) })
go func() { go func() {
//提前2秒续约 避免续约操作缓慢时租约过期
ticker := time.NewTicker(time.Duration(registerTTL-2) * time.Second) ticker := time.NewTicker(time.Duration(registerTTL/3) * time.Second)
defer ticker.Stop() defer ticker.Stop()
for { for {
select { select {