lily_website

πŸ“œ Base

⬅️ Back 🏠 Docs Root

This module provides foundational components for ARQ workers, including a wrapper for the ARQ Redis client (ArqService), common startup and shutdown hooks (base_startup, base_shutdown), and a base class for worker settings (BaseArqSettings).

ArqService Class

The ArqService acts as a convenient wrapper around the arq library’s Redis client, simplifying the management of Redis connection pools and job enqueuing.

Initialization (__init__)

def __init__(self, redis_settings: RedisSettings):

Initializes the ArqService with Redis connection settings.

init Method

async def init(self):

Asynchronously initializes the ARQ Redis connection pool. This method should be called once during application startup.

close Method

async def close(self):

Asynchronously closes the ARQ Redis connection pool. This method should be called during application shutdown to release resources.

enqueue_job Method

async def enqueue_job(self, function: str, *args: Any, **kwargs: Any) -> Any | None:

Enqueues a job into the ARQ queue.

Returns: Any | None: The ARQ job object if successfully enqueued, otherwise None.

base_startup Function

async def base_startup(ctx: dict) -> None:

An asynchronous function providing basic startup logic for all ARQ workers. It logs an informational message.

base_shutdown Function

async def base_shutdown(ctx: dict) -> None:

An asynchronous function providing basic shutdown logic for all ARQ workers. It logs an informational message.

BaseArqSettings Class

This class defines common base settings for all ARQ workers. Worker-specific settings should inherit from this class and override attributes as needed.

Attributes