from __future__ import annotations from collections.abc import Awaitable, Callable from typing import Protocol, runtime_checkable from yuxi.channel.domain.service.message_context import MessageContext CallNext = Callable[[MessageContext], Awaitable[MessageContext]] @runtime_checkable class Middleware(Protocol): @property def name(self) -> str: ... async def process(self, ctx: MessageContext, call_next: CallNext) -> MessageContext: ...