{"id":19285797,"url":"https://github.com/zhu327/doge","last_synced_at":"2025-07-27T13:05:33.140Z","repository":{"id":50391828,"uuid":"125386538","full_name":"zhu327/doge","owner":"zhu327","description":"Doge is a high-performance, Python based, open source RPC framework","archived":false,"fork":false,"pushed_at":"2025-01-09T09:20:06.000Z","size":128,"stargazers_count":166,"open_issues_count":2,"forks_count":28,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-24T01:07:31.701Z","etag":null,"topics":["doge","microservices","rpc","rpc-framework","service-discovery","service-oriented","service-registry"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhu327.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-15T15:19:48.000Z","updated_at":"2025-05-09T02:10:45.000Z","dependencies_parsed_at":"2025-02-28T14:13:09.174Z","dependency_job_id":"6d327016-fd4f-481c-9a53-4f58b3162430","html_url":"https://github.com/zhu327/doge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhu327/doge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhu327%2Fdoge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhu327%2Fdoge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhu327%2Fdoge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhu327%2Fdoge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhu327","download_url":"https://codeload.github.com/zhu327/doge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhu327%2Fdoge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267361489,"owners_count":24074938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["doge","microservices","rpc","rpc-framework","service-discovery","service-oriented","service-registry"],"created_at":"2024-11-09T21:46:42.590Z","updated_at":"2025-07-27T13:05:33.065Z","avatar_url":"https://github.com/zhu327.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doge\n\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/zhu327/doge/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/zhu327/doge.svg?branch=master)](https://travis-ci.org/zhu327/doge)\n[![codecov](https://codecov.io/gh/zhu327/doge/branch/master/graph/badge.svg)](https://codecov.io/gh/zhu327/doge)\n[![codebeat badge](https://codebeat.co/badges/1624b195-bbf5-43d0-9f9d-d330ca09ab76)](https://codebeat.co/projects/github-com-zhu327-doge-master)\n\nDoge is a Python RPC framework like [Alibaba Dubbo](http://dubbo.io/) and [Weibo Motan](https://github.com/weibocom/motan).\n\n## Features\n\n![doge](https://camo.githubusercontent.com/51ff9a1d5530f269f3074e9172483acf14c73eb8/687474703a2f2f6e2e73696e61696d672e636e2f746563682f7472616e73666f726d2f32303136303531302f4a7458792d66787279686875323338323938372e6a7067)\n\n- 服务治理, 服务注册, 服务发现\n- 高可用策略, failover, backupRequestHA\n- 负载均衡策略, RandomLB, RoundrobinLB\n- 限流策略, gevent Pool\n- 功能扩展, Opentracing, Prometheus\n\n## Quick Start\n\n### Installation\n\n```sh\npip install dogerpc\n```\n\n你可以在[examples](https://github.com/zhu327/doge/tree/master/examples)找到以下实例\n\n### Doge server\n\n1. 新建server端配置文件\n\n```yml\nregistry:  # 注册中心\n  protocol: etcd  # 注册协议, 支持 etcd 与 direct, 默认 etcd\n  host: 127.0.0.1  # 注册中心 host\n  port: 2379  # 注册中心 port\n  # \"address\": \"127.0.0.1:2379,127.0.0.1:4001\",  # 注册中心地址, 如果有etcd集群, 可配置多个node\n  ttl: 10  # etcd注册ttl, 用于server的心跳检查, 默认10s\nservice:\n  name: test  # 服务名称\n  node: n1  # 节点名称\n  host: 127.0.0.1  # 服务暴露ip\n  port: 4399  # 服务暴露port\n  limitConn: 100  # 服务最大连接数, 可选, 默认不限制\n  filters:  # 服务端扩展中间件\n    - doge.filter.tracing.TracingServerFilter  # opentracing\n    - doge.filter.metrics.MetricsServerFilter  # prometheus\n```\n\n2. 定义RPC methods类, 启动服务\n\n```python\n# coding: utf-8\n\nfrom gevent import monkey\nmonkey.patch_socket()  # 依赖gevent\n\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n\nfrom doge.rpc.server import new_server\n\n\n# 定义rpc方法类\nclass Sum(object):\n    def sum(self, x, y):\n        return x + y\n\n\nif __name__ == '__main__':\n    server = new_server('server.yaml')  # 基于配置文件实例化server对象\n    server.load(Sum)  # 加载暴露rpc方法类\n    server.run()  # 启动服务并注册节点信息到注册中心\n```\n\n### Doge client\n\n1. 新建client端配置文件\n\n```yml\nregistry:  # 注册中心\n  protocol: etcd  # 注册协议, 支持 etcd 与 direct, 默认 etcd\n  host: 127.0.0.1  # 注册中心 host\n  port: 2379  # 注册中心 port\n  # \"address\": \"127.0.0.1:2379,127.0.0.1:4001\",  # 注册中心地址, 如果有etcd集群, 可配置多个node\n  ttl: 10  # etcd注册ttl, 用于server的心跳检查, 默认10s\nrefer:\n  haStrategy: failover  # 高可用策略, 支持 failover backupRequestHA, 默认failover\n  loadBalance: RoundrobinLB  # 负载均衡策略, 支持 RandomLB RoundrobinLB, 默认RoundrobinLB\n  filters:  # 客户端扩展中间件\n    - doge.filter.tracing.TracingClientFilter  # opentracing\n    - doge.filter.metrics.MetricsClientFilter  # prometheus\n```\n\n2. 创建client并call远程方法\n\n```python\n# coding: utf-8\n\nfrom __future__ import print_function\n\nfrom gevent import monkey\nmonkey.patch_socket()\n\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n\nfrom doge.rpc.client import Cluster\n\nif __name__ == '__main__':\n    cluster = Cluster('client.yaml')  # 基于配置文件实例化Cluster对象\n    client = cluster.get_client(\"test\")  # 获取服务名对应的Client对象\n    print(client.call('sum', 1, 2))  # 远程调用服务Sum类下的sum方法\n```\n\n### Doge filter\n\n`filter`是Doge提供的自定义中间件扩展机制, 当前提供了`jaeger`链路跟踪与`Prometheus`的metrics, `filter`分为客户端`filter`与服务端`filter`, 具体的实例可以参考`filter`目录下的`tracing.py`\n\n#### Metrics\n\n在使用`Prometheus`监控时, 需要在服务节点上配置环境变量`prometheus_multiproc_dir`用于存储`Gunicorn`启动多进程时的`metrics`数据, 然后在服务节点启动`Prometheus Python Exporter`\n\n\u003chttps://gist.github.com/zhu327/56cdb58a21a750fb5ca5ae7ccd3e0112\u003e\n\n如何在多进程下使用`Prometheus`请[参考这里]( https://github.com/prometheus/client_python#multiprocess-mode-gunicorn )\n\n## Doge json gateway\n\n基于Bottle实现的json rpc gateway\n\n\u003chttps://gist.github.com/zhu327/24c8262dc40c5de7eeaddbfc572f4215\u003e\n\n## Gunicorn server\n\n创建`app.py`, 沿用example中的配置文件`server.json`\n\n```python\n# coding: utf-8\n\nfrom doge.rpc.server import new_server\n\n\n# 定义rpc方法类\nclass Sum(object):\n    def sum(self, x, y):\n        return x + y\n\n\nserver = new_server('server.yaml')  # 基于配置文件实例化server对象\nserver.load(Sum)  # 加载暴露rpc方法类\n```\n\n创建`configs.py`, 填写的bind必须与`server.yaml`配置的监听端口一致\n```python\nfrom doge.gunicorn.configs import *\n\nbind = \"127.0.0.1:4399\"\n```\n\n启动Gunicorn\n\n```shell\ngunicorn app:server -c configs.py\n```\n\n## Requirements\n\n- [gevent](https://github.com/gevent/gevent)\n- [mprpc](https://github.com/studio-ousia/mprpc)\n- [python-etcd](https://github.com/jplana/python-etcd)\n- [pyformance](https://github.com/omergertel/pyformance)\n- [pyyaml](https://github.com/yaml/pyyaml)\n- [prometheus_client](https://github.com/prometheus/client_python)\n- [jaeger-client](https://github.com/monsterxx03/jaeger-client-python)\n\n## License\n\nApache License, Version 2.0 \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhu327%2Fdoge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhu327%2Fdoge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhu327%2Fdoge/lists"}