Skip to main content

YDB integration for taskiq

Project description

taskiq + ydb

Python Linters

Plugin for taskiq that adds a new result backend and broker based on YDB.

Installation

This project can be installed using pip/poetry/uv (choose your preferred package manager):

pip install taskiq-ydb

Usage

Let's see the example with the redis broker and YDB result backend:

# example.py
import asyncio

from ydb.aio.driver import DriverConfig

from taskiq_ydb import YdbBroker, YdbResultBackend


driver_config = DriverConfig(
    endpoint='grpc://localhost:2136',
    database='/local',
)

broker = YdbBroker(
    driver_config=driver_config,
).with_result_backend(YdbResultBackend(driver_config=driver_config))


@broker.task(task_name='best_task_ever')
async def best_task_ever() -> str:
    """Solve all problems in the world."""
    return 'Problems solved!'


async def main() -> None:
    """Start the application with broker."""
    await broker.startup()
    task = await best_task_ever.kiq()
    result = await task.wait_result()
    print(f'Task result: {result.return_value}')
    await broker.shutdown()


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Example can be run using the following command:

# Start broker
python3 -m example
# Start worker for executing command
taskiq worker example:broker

Configuration

Broker:

  • driver_config: connection config for YDB client, you can read more about it in YDB documentation;
  • topic_path: path to the topic where tasks will be stored, default is /taskiq-tasks;
  • connection_timeout: timeout for connection to database during startup, default is 5 seconds.
  • read_timeout: timeout for read topic operation, default is 5 seconds.

Result backend:

  • driver_config: connection config for YDB client, you can read more about it in YDB documentation;
  • table_name: name of the table in PostgreSQL to store TaskIQ results;
  • serializer: type of TaskiqSerializer default is PickleSerializer;
  • pool_size: size of the connection pool for YDB client, default is 5;
  • connection_timeout: timeout for connection to database during startup, default is 5 seconds.

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

taskiq_ydb-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

taskiq_ydb-0.2.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_ydb-0.2.0.tar.gz.

File metadata

  • Download URL: taskiq_ydb-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.16

File hashes

Hashes for taskiq_ydb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 13f3f912b6dad1dee733fc66e18ac44525d91a661fd23beaba6ae5ed48aca339
MD5 bd2592177be6259b6a099091924ebbf3
BLAKE2b-256 2b8301dbaabbe475b07c7118dbc27fa6396c0896786d04f01c2c381117521007

See more details on using hashes here.

File details

Details for the file taskiq_ydb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: taskiq_ydb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.16

File hashes

Hashes for taskiq_ydb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e48b35b0e15532c409569cb9b30a98e5d9b3bffeddb68c6670b24408fd2280
MD5 446ad16711933d18269a78177d1fbbc7
BLAKE2b-256 ea18a88c12ac87cf5a34e4eedbfe043d1338f9abb9aadbb288486c23c482fc28

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