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 to store task results;
  • table_primary_key_type: type of primary key in task results table, default is uuid;
  • 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.3.0.tar.gz (9.7 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.3.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskiq_ydb-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ab57f90c949649c38c90c56f67e535bcfa62db6a04c7cca450f5843556248b99
MD5 7e1a4ca9544916113a99edf1a8686e3c
BLAKE2b-256 7b6590d7c83dc44e2e39a0158d45e5547006607745000ab9ae4bc3b4e9d912cf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for taskiq_ydb-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05cca676204e5c085494a1eb009d82a6aead056540da7a35e7c4f4846e9d000a
MD5 47d4551e1cabce5fb29f352cfe0515df
BLAKE2b-256 4196b5c47a040154eafd8fa39077b0688cdd08dfe524024420276cb68502f3b2

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