Skip to main content

Asynchronous wrapper for the python pulsar-client.

Project description

aiopulsar-py

aiopulsar-py is a Python 3.5+ module that makes it possible to interact with pulsar servers with asyncio. aiopulsar-py serves as an asynchronous wrapper for the official python pulsar-client and preserves the look and feel of the original pulsar-client. It is written using the async/await syntax and hence not compatible with Python versions older than 3.5. Internally, aiopulsar-py employs threads to avoid blocking the event loop.

aiopulsar-py takes inspiration from other asyncio wrappers released in the aio-libs project.

Basic example

aiopulsar-py is built around the python pulsar-client and provides the same api. You just need to use asynchronous context managers and await for every method. Setting up a pulsar client that can be used to create readers, producers and consumers requires a call to the aiopulsar.connect method.

import asyncio
import aiopulsar
import pulsar


async def test_example():
    topic = "persistent://some-test-topic/"

    async with aiopulsar.connect("localhost") as client:
        async with client.subscribe(
            topic=topic,
            subscription_name='my-subscription',
            consumer_name="my-consumer",
            initial_position=pulsar.InitialPosition.Earliest,
        ) as consumer:
            while True:
                msg = await consumer.receive()
                print(msg)

loop = asyncio.get_event_loop()
loop.run_until_complete(test_example())

Install

aiopulsar-py cannot be installed on windows systems since the wrapped pulsar-client library only functions on Linux and MacOS. The package is available on PyPi and can be installed with:

pip install aiopulsar-py

Contributing

You can contribute to the project by reporting an issue. This is done via GitHub. Please make sure to include information on your environment and please make sure that you can express the issue with a reproducible test case.

You can also contribute by making pull requests. To install the project please use poetry:

poetry install

The project relies on mypy, black and flake8 and these are configured as git hooks. To configure the git hooks run:

poetry run githooks setup

Every time the git hooks are changed in the [tool.githooks] section of pyproject.toml you will need to set up the git hooks again with the command above.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiopulsar-py-0.0.0a0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiopulsar_py-0.0.0a0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file aiopulsar-py-0.0.0a0.tar.gz.

File metadata

  • Download URL: aiopulsar-py-0.0.0a0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for aiopulsar-py-0.0.0a0.tar.gz
Algorithm Hash digest
SHA256 0dbf56b0348757519c8edb46917860100a61e4fc6d2a6633e61a6b158a99c6e1
MD5 b3952746aa8257e9ee29f245d4a95b03
BLAKE2b-256 767103eb56fb91068486c327937bd43f17a16f0037fe13b7f2ed55552a444e4f

See more details on using hashes here.

File details

Details for the file aiopulsar_py-0.0.0a0-py3-none-any.whl.

File metadata

  • Download URL: aiopulsar_py-0.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for aiopulsar_py-0.0.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 15555e74af92b716a024bf8a2875978b82e54f952c09e838fa1bdcf32f15211b
MD5 6820a2e72b687682a1b2dd0a1e626b74
BLAKE2b-256 6c29328c6736a3e22f684f6e3a17a0ca5a4a3a70577496939a69c37f1f5363a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page