thrift 客户端 ,负载均衡 连接池

来源:互联网 发布:天津平面设计美工培训 编辑:程序博客网 时间:2024/06/03 16:56

thrift 客户端 负载均衡


https://github.com/yikangfeng/thrift-protocol-client

https://github.com/cyfonly/ThriftJ

            TestThriftJ.Client client = thriftClient.iface(TestThriftJ.Client.class);

利用了代理类,实现了拦截器的.


问题: thrfit 生成的代码工具,将接口实现  helloWorld.client和socket 连接一对一绑定.

    要求接口是单例的,无状态.

       1. 无法连接池

       2. 无法负载均衡

解决: thrfit 客户端可以独立构建

       1. THttpClient

        2.默认继承TServiceClient

 故可以代理一个接口,将接口代理给一个 server 池,每个 server 有一个连接池.