from __future__ import annotations

from typing import Any, Protocol

from flownet.api.actor_method_ref import ActorMethodRef
from flownet.core.request import FlowRequest
from flownet.core.types import PayloadData


class EnginePort(Protocol):
    def local_address(self) -> str:
        ...

    async def forward_flowrequest(self, address: str, request: FlowRequest) -> Any:
        ...

    def invoke_local(
        self,
        rmf: ActorMethodRef,
        payload: PayloadData,
        request: FlowRequest,
    ) -> Any:
        ...

    async def handle_actor_call(self, rmf: ActorMethodRef, *args, **kwargs) -> Any:
        ...

    async def send_ack(
        self,
        origin_address: str,
        coordinator_target: str,
        request_id: str,
        delta: int,
    ) -> None:
        ...

    async def send_flow_error(
        self,
        origin_address: str,
        actor_id: str,
        request_id: str,
        *,
        error_type: str,
        message: str,
        traceback_text: str,
        event: Any | None = None,
    ) -> None:
        ...

    async def resolve_stateless_op(self, op_ref: Any) -> Any:
        ...

    def submit_runtime_coro(self, coro: Any) -> Any:
        ...


__all__ = ["EnginePort"]
