mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
d5633ebad7371c9848228f39103108cb6bc2eafc
Fixed #4668 ``` // client package main import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/contrib/registry/etcd/v2" ) func main() { gsvc.SetRegistry(etcd.New(`etcd.etcd.orb.local:2379`)) var ( ctx = gctx.New() client = g.Client() ) client.SetDiscovery(gsvc.GetRegistry()) res := client.GetContent(ctx, `http://hello.svc/`) g.Log().Info(ctx, res) } // server package main import ( "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" ) func main() { gsvc.SetRegistry(etcd.New(`etcd.etcd.orb.local:2379`)) s := g.Server(`hello.svc`) s.BindHandler("/", func(r *ghttp.Request) { g.Log().Info(r.Context(), `request received`) r.Response.Write(`Hello world`) }) s.Run() } ``` ``` /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105 2. context deadline exceeded Stack: 1. github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107 {"level":"warn","ts":"2026-01-30T22:30:33.863409+0800","logger":"etcd-client","caller":"v3@v3.5.17/retry_interceptor.go:63","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0x1400023a780/etcd.etcd.orb.local:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing: dial tcp 192.168.138.6:2379: connect: operation timed out\""} 2026-01-30T22:30:33.863+08:00 [ERRO] keepalive retry register failed, will retry in 2s: etcd grant failed with keepalive ttl "10s": context deadline exceeded 1. etcd grant failed with keepalive ttl "10s" 1). github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doRegisterLease /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:38 2). github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105 2. context deadline exceeded Stack: 1. github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107 {"level":"warn","ts":"2026-01-30T22:30:40.865971+0800","logger":"etcd-client","caller":"v3@v3.5.17/retry_interceptor.go:63","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0x1400023a780/etcd.etcd.orb.local:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing: dial tcp 192.168.138.6:2379: connect: operation timed out\""} 2026-01-30T22:30:40.866+08:00 [ERRO] keepalive retry register failed, will retry in 3s: etcd grant failed with keepalive ttl "10s": context deadline exceeded 1. etcd grant failed with keepalive ttl "10s" 1). github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doRegisterLease /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:38 2). github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105 2. context deadline exceeded Stack: 1. github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107 2026-01-30T22:30:43.903+08:00 [DEBU] etcd put success with key "/service/default/default/hello.svc/latest/192.168.27.229:60201,192.168.139.3:60201,192.168.163.0:60201", value "{"insecure":true,"protocol":"http"}", lease "7587892536770637317" 2026-01-30T22:30:43.904+08:00 [INFO] keepalive retry register success for service "/service/default/default/hello.svc/latest/192.168.27.229:60201,192.168.139.3:60201,192.168.163.0:60201" 2026-01-30T22:30:51.385+08:00 [INFO] {e0ffad1cac888f18eed5ef7a3ba3f6d0} request received 2026-01-30T22:30:52.121+08:00 [INFO] {78ca8848ac888f18573a386e0b596eaa} request received ``` --------- Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
refactor(container): add default nil checker, rename RegisterNilChecker to SetNilChecker, migrate instance containers to type-safe generics (#4630)
refactor(container): add default nil checker, rename RegisterNilChecker to SetNilChecker, migrate instance containers to type-safe generics (#4630)
refract(gerror): add ITextArgs interface and its implements, mainly for i18n that needs text and args separately (#4597)
refactor(container): add default nil checker, rename RegisterNilChecker to SetNilChecker, migrate instance containers to type-safe generics (#4630)
English | 简体中文
A powerful framework for faster, easier, and more efficient project development.
Installation
go get -u github.com/gogf/gf/v2
Documentation
- Official Site: https://goframe.org
- Official Site(en): https://goframe.org/en
- 国内镜像: https://goframe.org.cn
- Mirror Site: https://pages.goframe.org
- Mirror Site: Offline Docs
- GoDoc API: https://pkg.go.dev/github.com/gogf/gf/v2
- Doc Source: https://github.com/gogf/gf-site
Contributors
💖 Thanks to all the contributors who made GoFrame possible 💖
License
GoFrame is licensed under the MIT License, 100% free and open-source, forever.
Languages
GO
100%
