streaq.types

class streaq.types.ReadStreamsCallback(**options: Any)

Bases: ResponseCallback[dict[str, list[list[list[str] | str]]] | None, dict[str, tuple[StreamEntry, …]] | None]

Transform Lua script output to same format as XREAD.

class streaq.types.StreamMessage(message_id: str, task_id: str, priority: str, enqueue_time: int)

Bases: object

Dataclass wrapping data stored in the Redis stream.

class streaq.types.Streaq(client: coredis.client.Client[AnyStr], name: StringT | None = None, code: StringT | None = None, replace: bool = False)

Bases: Library[str]

FFI stubs for Lua functions in streaq.lua

NAME = 'streaq'

Class variable equivalent of the :paramref:`Library.name` argument.

exception streaq.types.StreaqCancelled

Bases: StreaqError

Similar to asyncio.CancelledError and trio.Cancelled, but can be raised manually.

exception streaq.types.StreaqError

Bases: Exception

Base class for all task queuing errors.

exception streaq.types.StreaqRetry(*args: Any, delay: timedelta | int | None = None, schedule: datetime | None = None)

Bases: StreaqError

An exception you can manually raise in your tasks to make sure the task is retried.

Parameters:
delay: timedelta | int | None = None

amount of time to wait before retrying the task; if None and schedule is not passed either, will be the number of tries squared, in seconds

schedule: datetime | None = None

specific datetime to retry the task at

class streaq.types.TaskContext(fn_name: str, task_id: str, timeout: timedelta | int | None, tries: int, ttl: timedelta | int | None)

Bases: object

Dataclass containing task-specific information like the try count.

class streaq.types.TaskDecorator(*args, **kwargs)

Bases: Protocol