Golang Go语言中推广自己写的grpc-go load balancing实现与及改造成自定义lb的github repo

Golang Go语言中推广自己写的grpc-go load balancing实现与及改造成自定义lb的github repo

grpc-go load balancing 的官方实现目前仅支持 rr,wrr 的实现好像是个半残品。

鉴于项目的需要,借鉴了 google 上的一些文章、grpc-go 的源码以及 etcd v3.5 的 clientv3 代码编写了此 repo 的代码,地址: https://github.com/xkeyideal/grpcbalance

lb 的实现其实只需要理解 resolver 与 balancer 的 interface 即可随心的改造成自己项目需要的实现方案。

本实现方案是基于 grpc v1.36.0 实现的,看了一下最新的 v1.37.0 与 v1.38.0 接口都是兼容的。

使用方法:

  1. 常规的 lb 方案可直接引用该 repo,特殊要求的 lb 不建议直接引用该 repo,可阅读代码了解原理后根据需求修改;
  2. 本代码没有实现 endpoints 动态变化的部分代码,但 resovler 里提供了 SetEndpoint 方法

希望能帮助有需要的人,enjoy it


更多关于Golang Go语言中推广自己写的grpc-go load balancing实现与及改造成自定义lb的github repo的实战教程也可以访问 https://www.itying.com/category-94-b0.html

回到顶部