YZ-Dubbo
有赞 Dubbo SDK - 基于 Tether 网关的 Dubbo RPC 调用封装
功能特性
- 🚀 简单易用: 提供简洁的函数式 API
- ⏱️ 超时控制: 支持自定义超时时间,默认3秒
安装
pip install yz-dubbo
快速开始
基础调用
from yz_dubbo import invoke
# 调用 Dubbo 服务
result = invoke(
service_name="com.youzan.service.UserService",
method_name="getUserInfo",
args=[{"userId": 123}]
)
print(result) # 直接返回响应数据
自定义 Headers
result = invoke(
service_name="com.youzan.service.OrderService",
method_name="createOrder",
args=[{"productId": 456, "quantity": 1}],
headers={
"X-Request-Id": "req-123",
"X-Tenant-Id": "tenant-456"
}
)
设置超时时间
result = invoke(
service_name="com.youzan.service.PaymentService",
method_name="pay",
args=[payment_data],
timeout=10000 # 10秒超时
)
错误处理
错误码对照表
| 错误码 | 说明 | 错误信息 |
|---|---|---|
10000001 |
网络超时 | NETWORK_TIMEOUT |
10000002 |
网络错误 | NETWORK_ERROR |
10000003 |
参数不能为空 | PARAMS_EMPTY_ERROR |
10000004 |
服务接口错误 | SERVICE_INTERFACE_ERROR |
异常处理示例
from yz_dubbo import invoke, YzDubboException, YzDubboErrorCode
try:
result = invoke(
service_name="com.youzan.service.UserService",
method_name="getUser",
args=[{"userId": 123}]
)
print(f"成功: {result}")
except YzDubboException as e:
print(f"错误码: {e.code}")
print(f"错误信息: {e.message}")
print(f"上下文: {e.context}")
# 根据错误码处理
if e.code == YzDubboErrorCode.NETWORK_TIMEOUT.code:
print("请求超时,请稍后重试")
elif e.code == YzDubboErrorCode.NETWORK_ERROR.code:
print("网络错误")
else:
print("其他错误")
许可证
MIT License
联系方式
- 项目地址:
/packages/yz_dubbo - 测试目录:
/tests/yz_dubbo
YZ-Dubbo - 让 Dubbo 调用更简单 🚀
Metadata
Release files for yz-dubbo 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yz_dubbo-0.1.4.tar.gz | 5.5 kB | Without provenance | Details for yz_dubbo-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yz_dubbo-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for yz_dubbo-0.1.4-py3-none-any.whl |
Total release size: 11.2 kB
Release files / yz_dubbo-0.1.4.tar.gz
| Download URL | yz_dubbo-0.1.4.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
653727b562fe018ed0fb8609f9f0a6d9d7ddfed5bcb0af8119542df038ed8ff5
|
|
BLAKE2b-256 checksum How to use checksums |
f5dd1887160b56e0d11512b7a157dee0e36907f15c1d362808c7a55d244bafd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / yz_dubbo-0.1.4-py3-none-any.whl
| Download URL | yz_dubbo-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1dfc3e7c2f5ff55709eebe33db06b870acb02c56bfa70bd6a524bdf14b1d4576
|
|
BLAKE2b-256 checksum How to use checksums |
13677783869047ab22748267daa5bd21fcd301e57c3ebff26e0082fa34181f30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for yz-dubbo 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.