from collections.abc import Callable
from typing import Any, ClassVar

import kombu
from celery.app.base import Celery
from celery.bootsteps import Blueprint, StartStopStep
from typing_extensions import override
from vine.promises import promise

__all__ = ("Consumer", "Evloop", "dump_body")

class Evloop(StartStopStep):
    name: ClassVar[str]  # pyright: ignore[reportIncompatibleVariableOverride]
    label: ClassVar[str]  # pyright: ignore[reportIncompatibleVariableOverride]

    def patch_all(self, c: Any) -> None: ...
    @override
    def start(self, c: Any) -> None: ...  # pyright: ignore[reportIncompatibleMethodOverride]  # ty: ignore[invalid-method-override]

def dump_body(m: Any, body: Any) -> str: ...

class Consumer:
    app: Celery
    hostname: str
    pool: Any
    connection: kombu.Connection | None
    blueprint: Blueprint
    Blueprint: type[Blueprint]
    Strategies: type[dict[Any, Any]]
    restart_count: int
    broker_connection_retry_attempt: int
    first_connection_attempt: bool
    init_callback: Callable[..., Any] | None

    def __init__(
        self,
        on_task_request: Callable[..., Any],
        init_callback: Callable[..., Any] = ...,
        hostname: str | None = None,
        pool: Any = None,
        app: Celery | None = None,
        timer: Any = None,
        controller: Any = None,
        hub: Any = None,
        amqheartbeat: float | None = None,
        worker_options: dict[str, Any] | None = None,
        disable_rate_limits: bool = False,
        initial_prefetch_count: int = 2,
        prefetch_multiplier: int = 1,
        **kwargs: Any,
    ) -> None: ...
    def bucket_for_task(self, type: Any) -> Any: ...
    def reset_rate_limits(self) -> None: ...
    def add_task_queue(
        self,
        queue: str | kombu.Queue,
        exchange: str | kombu.Exchange | None = None,
        exchange_type: str | None = None,
        routing_key: str | None = None,
        **options: Any,
    ) -> kombu.Queue: ...
    def cancel_task_queue(self, queue: str | kombu.Queue) -> None: ...
    def apply_eta_task(self, task: Any) -> None: ...
    def call_soon(
        self,
        p: Callable[..., Any],
        *args: Any,
        **kwargs: Any,
    ) -> None: ...
    def cancel_active_requests(self) -> None: ...
    def connect(self) -> kombu.Connection: ...
    def connection_for_read(
        self, heartbeat: float | None = None
    ) -> kombu.Connection: ...
    def connection_for_write(
        self, url: str | None = None, heartbeat: float | None = None
    ) -> kombu.Connection: ...
    def create_task_handler(
        self, promise: type[promise] = ...
    ) -> Callable[..., Any]: ...
    def ensure_connected(self, conn: kombu.Connection) -> kombu.Connection: ...
    def loop_args(self) -> tuple[Any, ...]: ...
    @property
    def max_prefetch_count(self) -> int: ...
    def on_close(self) -> None: ...
    def on_connection_error_after_connected(self, exc: Exception) -> None: ...
    def on_connection_error_before_connected(self, exc: Exception) -> None: ...
    def on_decode_error(self, message: Any, exc: Exception) -> None: ...
    def on_invalid_task(self, body: Any, message: Any, exc: Exception) -> None: ...
    def on_ready(self) -> None: ...
    def on_send_event_buffered(self) -> Callable[..., Any]: ...
    def on_unknown_message(self, body: Any, message: Any) -> None: ...
    def on_unknown_task(self, body: Any, message: Any, exc: Exception) -> None: ...
    def perform_pending_operations(self) -> None: ...
    def register_with_event_loop(self, hub: Any) -> None: ...
    def stop(self) -> None: ...
    def start(self) -> None: ...
    def shutdown(self) -> None: ...
    @property
    def timer(self) -> Any: ...
    def update_strategies(self) -> None: ...
