# Apache Dubbo for Python
![License](https://img.shields.io/github/license/apache/dubbo-python)
![GitHub last commit](https://img.shields.io/github/last-commit/apache/dubbo-python)
![GitHub branch check runs](https://img.shields.io/github/check-runs/apache/dubbo-python/main)
---
<p align="center">
<img src="https://cn.dubbo.apache.org/imgs/nav_logo2.png" alt="Logo" width="40%" />
</p>
Apache Dubbo is an easy-to-use, high-performance WEB and RPC framework with builtin service discovery, traffic management, observability, security features, tools and best practices for building enterprise-level microservices.
Dubbo-python is a Python implementation of the [triple protocol](https://dubbo.apache.org/zh-cn/overview/reference/protocols/triple-spec/) (a protocol fully compatible with gRPC and friendly to HTTP) and various features designed by Dubbo for constructing microservice architectures.
Visit [the official website](https://dubbo.apache.org/) for more information.
### 🚧 Early-Stage Project 🚧
> **Disclaimer:** This project is in the early stages of development. Features are subject to change, and some components may not be fully stable. Contributions and feedback are welcome as the project evolves.
## Features
- **Service Discovery**: Zookeeper
- **Load Balance**: Random, CPU
- **RPC Protocols**: Triple(gRPC compatible and HTTP-friendly)
- **Transport**: asyncio(uvloop)
- **Serialization**: Customizable(protobuf, json...)
## Installation
Before you start, make sure you have **`python 3.11+`** installed.
1. Install from source
```sh
git clone https://github.com/apache/dubbo-python.git
cd dubbo-python && pip install .
```
## Getting started
Get up and running with Dubbo-Python in just 5 minutes by following our [Quick Start Guide](https://github.com/apache/dubbo-python/tree/main/samples).
It's as simple as the code snippet below. With just a few lines of code, you can launch a fully functional point-to-point RPC service:
1. Build and start the server
```python
import dubbo
from dubbo.configs import ServiceConfig
from dubbo.proxy.handlers import RpcMethodHandler, RpcServiceHandler
class UnaryServiceServicer:
def say_hello(self, message: bytes) -> bytes:
print(f"Received message from client: {message}")
return b"Hello from server"
def build_service_handler():
# build a method handler
method_handler = RpcMethodHandler.unary(
method=UnaryServiceServicer().say_hello, method_name="unary"
)
# build a service handler
service_handler = RpcServiceHandler(
service_name="org.apache.dubbo.samples.HelloWorld",
method_handlers=[method_handler],
)
return service_handler
if __name__ == "__main__":
# build service config
service_handler = build_service_handler()
service_config = ServiceConfig(
service_handler=service_handler, host="127.0.0.1", port=50051
)
# start the server
server = dubbo.Server(service_config).start()
input("Press Enter to stop the server...\n")
```
1. Build and start the Client
```python
import dubbo
from dubbo.configs import ReferenceConfig
class UnaryServiceStub:
def __init__(self, client: dubbo.Client):
self.unary = client.unary(method_name="unary")
def say_hello(self, message: bytes) -> bytes:
return self.unary(message)
if __name__ == "__main__":
# Create a client
reference_config = ReferenceConfig.from_url(
"tri://127.0.0.1:50051/org.apache.dubbo.samples.HelloWorld"
)
dubbo_client = dubbo.Client(reference_config)
unary_service_stub = UnaryServiceStub(dubbo_client)
# Call the remote method
result = unary_service_stub.say_hello(b"Hello from client")
print(result)
```
## License
Apache Dubbo-python software is licensed under the Apache License Version 2.0. See
the [LICENSE](https://github.com/apache/dubbo-python/blob/main/LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/apache/dubbo-python",
"name": "apache-dubbo",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "dubbo, rpc, dubbo-python, http2, network",
"author": "Apache Dubbo Community",
"author_email": "dev@dubbo.apache.org",
"download_url": "https://files.pythonhosted.org/packages/a3/41/fc5470047e8fd433432c8212f5bcb3bdaed30a0965b79ffeffc46cfd6890/apache-dubbo-3.0.0b1.tar.gz",
"platform": null,
"description": "# Apache Dubbo for Python\n\n![License](https://img.shields.io/github/license/apache/dubbo-python)\n![GitHub last commit](https://img.shields.io/github/last-commit/apache/dubbo-python)\n![GitHub branch check runs](https://img.shields.io/github/check-runs/apache/dubbo-python/main)\n\n---\n\n<p align=\"center\">\n <img src=\"https://cn.dubbo.apache.org/imgs/nav_logo2.png\" alt=\"Logo\" width=\"40%\" />\n</p>\n\nApache Dubbo is an easy-to-use, high-performance WEB and RPC framework with builtin service discovery, traffic management, observability, security features, tools and best practices for building enterprise-level microservices.\n\nDubbo-python is a Python implementation of the [triple protocol](https://dubbo.apache.org/zh-cn/overview/reference/protocols/triple-spec/) (a protocol fully compatible with gRPC and friendly to HTTP) and various features designed by Dubbo for constructing microservice architectures.\n\nVisit [the official website](https://dubbo.apache.org/) for more information.\n\n### \ud83d\udea7 Early-Stage Project \ud83d\udea7\n\n> **Disclaimer:** This project is in the early stages of development. Features are subject to change, and some components may not be fully stable. Contributions and feedback are welcome as the project evolves.\n\n## Features\n\n- **Service Discovery**: Zookeeper\n- **Load Balance**: Random, CPU\n- **RPC Protocols**: Triple(gRPC compatible and HTTP-friendly)\n- **Transport**: asyncio(uvloop)\n- **Serialization**: Customizable(protobuf, json...)\n\n\n\n## Installation\n\nBefore you start, make sure you have **`python 3.11+`** installed.\n\n1. Install from source\n\n ```sh\n git clone https://github.com/apache/dubbo-python.git\n cd dubbo-python && pip install .\n ```\n\n\n## Getting started\n\nGet up and running with Dubbo-Python in just 5 minutes by following our [Quick Start Guide](https://github.com/apache/dubbo-python/tree/main/samples).\n\nIt's as simple as the code snippet below. With just a few lines of code, you can launch a fully functional point-to-point RPC service:\n\n1. Build and start the server\n\n ```python\n import dubbo\n from dubbo.configs import ServiceConfig\n from dubbo.proxy.handlers import RpcMethodHandler, RpcServiceHandler\n \n \n class UnaryServiceServicer:\n def say_hello(self, message: bytes) -> bytes:\n print(f\"Received message from client: {message}\")\n return b\"Hello from server\"\n \n \n def build_service_handler():\n # build a method handler\n method_handler = RpcMethodHandler.unary(\n method=UnaryServiceServicer().say_hello, method_name=\"unary\"\n )\n # build a service handler\n service_handler = RpcServiceHandler(\n service_name=\"org.apache.dubbo.samples.HelloWorld\",\n method_handlers=[method_handler],\n )\n return service_handler\n \n \n if __name__ == \"__main__\":\n # build service config\n service_handler = build_service_handler()\n service_config = ServiceConfig(\n service_handler=service_handler, host=\"127.0.0.1\", port=50051\n )\n # start the server\n server = dubbo.Server(service_config).start()\n \n input(\"Press Enter to stop the server...\\n\")\n ```\n\n1. Build and start the Client\n\n ```python\n import dubbo\n from dubbo.configs import ReferenceConfig\n \n \n class UnaryServiceStub:\n def __init__(self, client: dubbo.Client):\n self.unary = client.unary(method_name=\"unary\")\n \n def say_hello(self, message: bytes) -> bytes:\n return self.unary(message)\n \n \n if __name__ == \"__main__\":\n # Create a client\n reference_config = ReferenceConfig.from_url(\n \"tri://127.0.0.1:50051/org.apache.dubbo.samples.HelloWorld\"\n )\n dubbo_client = dubbo.Client(reference_config)\n unary_service_stub = UnaryServiceStub(dubbo_client)\n \n # Call the remote method\n result = unary_service_stub.say_hello(b\"Hello from client\")\n print(result)\n \n ```\n\n \n\n## License\n\nApache Dubbo-python software is licensed under the Apache License Version 2.0. See\nthe [LICENSE](https://github.com/apache/dubbo-python/blob/main/LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "Apache License Version 2.0",
"summary": "Python Implementation For Apache Dubbo.",
"version": "3.0.0b1",
"project_urls": {
"Homepage": "https://github.com/apache/dubbo-python"
},
"split_keywords": [
"dubbo",
" rpc",
" dubbo-python",
" http2",
" network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a341fc5470047e8fd433432c8212f5bcb3bdaed30a0965b79ffeffc46cfd6890",
"md5": "921b8cae34cefdd312edf957de9db0a9",
"sha256": "8afc5501360df0ab8b01b372687b16c5142dcc1cfb165018d8c03281afad2b5c"
},
"downloads": -1,
"filename": "apache-dubbo-3.0.0b1.tar.gz",
"has_sig": false,
"md5_digest": "921b8cae34cefdd312edf957de9db0a9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 73366,
"upload_time": "2025-01-26T11:52:04",
"upload_time_iso_8601": "2025-01-26T11:52:04.776903Z",
"url": "https://files.pythonhosted.org/packages/a3/41/fc5470047e8fd433432c8212f5bcb3bdaed30a0965b79ffeffc46cfd6890/apache-dubbo-3.0.0b1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-26 11:52:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "apache",
"github_project": "dubbo-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "apache-dubbo"
}