- Part Ⅰ 开发起步
- Part Ⅱ 注册中心
- Part Ⅲ 特性
- Part Ⅳ 插件
- Part Ⅴ 其它
- Part Ⅵ 网关
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
3.3 Fork模式
Example: fork
Fork
is a method of XClient
and you can use it to send a request to all servers that contains this service.
If any of servers returns response whithout an error, Fork
will return for this XClient. If all servers return errors, Fork
returns an error of those errors.
It is like thee Failbackup
mode. Failbackup
uses at most two requests but Fork
uses more requests (same to count of servers).
func main() {
……
xclient := client.NewXClient("Arith", client.Failover, client.RoundRobin, d, client.DefaultOption)
defer xclient.Close()
args := &example.Args{
A: 10,
B: 20,
}
for {
reply := &example.Reply{}
err := xclient.Fork(context.Background(), "Mul", args, reply)
if err != nil {
log.Fatalf("failed to call: %v", err)
}
log.Printf("%d * %d = %d", args.A, args.B, reply.C)
time.Sleep(1e9)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论