Skip to main content

YDB integration for taskiq

Project description

taskiq + ydb

Python Linters

Plugin for taskiq that adds a new result backend 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
import logging

import taskiq_redis
from ydb.aio.driver import DriverConfig

from taskiq_ydb import YdbResultBackend


logger = logging.getLogger(__name__)

result_backend = YdbResultBackend(
    driver_config=DriverConfig(
        endpoint="grpc://localhost:2136",
        database="/local",
    ),
)

# Or you can use PubSubBroker if you need broadcasting
broker = taskiq_redis.ListQueueBroker(
    url="redis://redis.taskiq-ydb.orb.local:6379",
).with_result_backend(result_backend)


@broker.task(task_name="best_task_ever")
async def best_task_ever() -> None:
    """Solve all problems in the world."""
    logger.info("Task started")
    await asyncio.sleep(2.0)
    logger.info("Task finished")


async def main() -> None:
    logger.info("Starting application")
    await broker.startup()
    logger.info("Broker started")
    await best_task_ever.kiq()
    logger.info("Task queued")
    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

  • 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 10.

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.1.0.tar.gz (6.3 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.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskiq_ydb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cceef4a60e7a4ddf65db7a4a2f7eaced345664e168caf7d1c5d96dc76319e50a
MD5 2b7380654b531c622465e4b81d0d50ee
BLAKE2b-256 040f4335d641d89e437b15078d7ece41a0ee1a35f4ae6d4982e770d531bed5e0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for taskiq_ydb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e386c071d9318483b6ae1185ed8f6de74d02730a17ad9631e24f1794e8c46d2f
MD5 fe0d76c53dcb8a6b1d983cd11d1ce6b5
BLAKE2b-256 37af0952d187fb487cf3069aedc41f10f6850801b906f4267abfd5640b0a5985

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