from abc import ABC, abstractmethod
from typing import Any, Callable, Union


class Parser(ABC):
    """Parsing contract for the message received by the processor."""

    @abstractmethod
    def parse(self, data: dict, event_type: str) -> Any:
        """Converts the decoded payload into a domain request object.

        Args:
            data: Payload already decoded from bytes to dict.
            event_type: Type of the event received by the message bus.
        """


ParserLike = Union["Parser", Callable[[dict, str], Any]]
