Giter Club home page Giter Club logo

dubbo-client-py's Introduction

Python Dubbo Client

实现客户端的负载均衡、配合Zookeeper自动发现服务功能

Python调用Dubbo接口的jsonrpc协议

请使用dubbo-rpc-jsonrpc 并在dubbo中配置protocol为jsonrpc协议 参考 https://github.com/ofpay/dubbo-rpc-jsonrpc

安装

下载代码
python setup.py install pip安装 pip install dubbo-client==1.0.0b5 Git安装
pip install git+http://git.dev.qianmi.com/tda/[email protected]
或者
pip install git+https://github.com/ofpay/[email protected]

在客户端实现负载均衡,服务发现

通过注册中心的zookeeper,获取服务的注册信息
dubbo-client-py支持配置多个zookeeper服务地址
"host": "192.168.1.183:2181,192.168.1.184:2181,192.168.1.185:2181"
然后通过代理实现负载均衡算法,调用服务端 支持Version、Group设置

Example

    config = ApplicationConfig('test_rpclib')
    service_interface = 'com.ofpay.demo.api.UserProvider'
    #registry包含了和zookeeper的连接,该对象需要缓存
    registry = ZookeeperRegistry('192.168.59.103:2181', config)
    user_provider = DubboClient(service_interface, registry, version='1.0')
    for i in range(1000):
        try:
            print user_provider.getUser('A003')
            print user_provider.queryUser(
                {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'})
            print user_provider.queryAll()
            print user_provider.isLimit('MAN', 'Joe')
            print user_provider('getUser', 'A005')

        except DubboClientError, client_error:
            print client_error
        time.sleep(5)

TODO

优化性能,将服务上下线的影响降到最小
支持Retry参数
支持权重调用
单元测试覆盖率

Licenses

MIT License

感谢

感谢 @jingpeicomp 同学做小白鼠,目前已经正常运行在生产环境数月,谢谢!

dubbo-client-py's People

Contributors

joecao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.