Skip to main content

Busrt Worker

BUS/RT是一个快速、灵活且非常易于使用的框架,它使用Rust/Tokio编写,受到NATS、ZeroMQ和Nanomsg的启发。

Busrt Worker是一个基于busrt消息中间件的异步框架,它对Python库进行了封装,使其更易于使用。

特点

  • 异步:Busrt Worker基于python asyncio异步引擎,可以轻松处理高并发请求。
  • 易用性:Busrt Worker对原生的busrt python客户端进行了封装,使用装饰器即可轻松创建rpc服务。
  • 高性能:BUS/RT 使用Rust/Tokio编写,具有出色的性能和可靠性。

用法

要使用Busrt Worker,请按照以下步骤操作:

  1. 安装Busrt Worker:pip install busrt-worker
  2. 导入Busrt Worker:在您的Python项目中导入Busrt Worker。
  3. 创建Busrt Worker App:创建一个App对象,并注册连接信息。
  4. 处理消息:使用装饰器指明消息处理方式。

以下是一个示例代码片段,演示如何使用Busrt Worker:

import asyncio

from loguru import logger

from busrtworker import App, ConnectionInfo
# 创建 App对象
app = App()

# 连接信息
api_ci = ConnectionInfo('api', 'localhost:9800', 'busrt.worker.test', static=True, topic='test/#')
caller_ci = ConnectionInfo('caller', 'localhost:9800', 'busrt.worker.test', static=True)

# 注册连接
api = app.registry(api_ci)
app.registry(caller_ci)

# rpc调用
@api.on_call()
def add(a, b):
    return a + b

# 主题订阅
@api.subscribe('test/:name')
def print_name(name: str):
    logger.info(f'{name} pub message')

# 钩子函数注册
@app.run_on_startup
async def test(server):
    async def call():
        await asyncio.sleep(1)
        logger.info(f'call remote add result {(await app.caller.add(api_ci.final_name,a=1, b=2))}')
        await app.caller.send('test/i_am_caller')
    asyncio.create_task(call())

# 启动程序
app.run()

License

The MIT License.

Metadata

Release files for busrt-worker 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for busrt-worker 0.1.7
File Size Uploaded Provenance Actions
busrt_worker-0.1.7.tar.gz 16.4 kB Without provenance Details for busrt_worker-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for busrt-worker 0.1.7
File Interpreter ABI Platform Actions
busrt_worker-0.1.7-py3-none-any.whl Python 3 none any Details for busrt_worker-0.1.7-py3-none-any.whl

Total release size: 37.2 kB

Release files / busrt_worker-0.1.7.tar.gz

Download URL busrt_worker-0.1.7.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5ff70d895afddfdc590593b312f1e023941b69f285a79e1b492f4090d6303cc9
BLAKE2b-256 checksum
How to use checksums
9192dcf8dc63b055b6544a8abc03b43eacea636691cf1db71c2ef8677ce7ac96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.5 Windows/10

Release files / busrt_worker-0.1.7-py3-none-any.whl

Download URL busrt_worker-0.1.7-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8a26f3a270d6ca3a07ef19e31c80638871a1237d6f3720640c237258442800c
BLAKE2b-256 checksum
How to use checksums
efeaca84bc1fe765e53309a5fb7ced66a548fdd82e2e9cddd64c2d48cb260197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.5 Windows/10

Security for busrt-worker 0.1.7

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page