增加DialWith的示例

This commit is contained in:
injoyai
2024-11-14 15:01:09 +08:00
parent d8eb8c3d11
commit 338e26af4e

View File

@@ -6,14 +6,22 @@ import (
) )
func Test(f func(c *tdx.Client)) { func Test(f func(c *tdx.Client)) {
for _, v := range tdx.Hosts {
c, err := tdx.Dial(v, tdx.WithDebug()) //重连方式1,优点,同一个客户端指针
if err != nil { c, err := tdx.DialWith(tdx.NewHostDial(tdx.Hosts, 0), tdx.WithDebug())
logs.PrintErr(err) logs.PanicErr(err)
continue
}
f(c) f(c)
<-c.Done() <-c.Done()
break
} //重连方式2
//for _, v := range tdx.Hosts {
// c, err := tdx.DialWith(v, tdx.WithDebug())
// if err != nil {
// logs.PrintErr(err)
// continue
// }
// f(c)
// <-c.Done()
// break
//}
} }