ForcePilot/backend/package/yuxi/channel/domain/middleware/middleware.py

17 lines
457 B
Python
Raw Normal View History

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: ...