Skeleton ready

This commit is contained in:
2026-07-08 23:01:55 +04:00
commit d9e5effdce
75 changed files with 1989 additions and 0 deletions

0
kernel/event/__init__.py Normal file
View File

16
kernel/event/listener.py Normal file
View File

@@ -0,0 +1,16 @@
from typing import Generic, TypeVar
from abc import ABC, abstractmethod
from punq import Container
T = TypeVar('T')
class Listener(ABC, Generic[T]):
_container: Container
def __init__(self, container: Container) -> None:
self._container = container
@abstractmethod
async def handle(self, event: str, payload: T) -> None:
pass

25
kernel/event/registrar.py Normal file
View File

@@ -0,0 +1,25 @@
from punq import Container
from typing import TypeVar
from pyee import EventEmitter
from kernel.event.listener import Listener
T = TypeVar('T')
class Registrar:
_container: Container
def __init__(self, container: Container) -> None:
self._container = container
def add_event_listener(
self,
event: str,
listener: type[Listener[T]]
) -> None:
async def callback(payload: T) -> None:
listener_instance = listener(self._container)
await listener_instance.handle(event, payload)
self._container.resolve(EventEmitter).on(event, callback)