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 YDB broker and 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.1.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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: taskiq_ydb-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 acc36c055a939fdd56dca4752708fcd40c06f178d645eb8ceb16ae5998977b1b
MD5 2e2b059fac14381ecd01265cdd53e040
BLAKE2b-256 238514c5ee75bb86f8b922efd00bb15a2da74ff1db5962eebeba1656ea4276cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: taskiq_ydb-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b15c6ec2143a445666912e16c8156f58552b3ebaecc3c544180cb86dac747cb1
MD5 eefb95be10dfc93e75fa490e17aa3ba5
BLAKE2b-256 b2418791e4d73a6bf5e48ba411b0cc88ad414dc63e5ba721c5c025b1457290ba

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