feat: add FastAPI, Entity base class, and health check endpoint
This commit is contained in:
18
domain/framework/entity.py
Normal file
18
domain/framework/entity.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from abc import ABC
|
||||
from dataclasses import replace
|
||||
from typing import Self
|
||||
|
||||
from domain.marketplace.domain_event import DomainEvent
|
||||
|
||||
|
||||
class Entity(ABC):
|
||||
_events: tuple[DomainEvent, ...] = ()
|
||||
|
||||
def raise_event(self, event: DomainEvent) -> Self:
|
||||
return replace(self, _events=(*self._events, event))
|
||||
|
||||
def get_changes(self) -> tuple[DomainEvent, ...]:
|
||||
return self._events
|
||||
|
||||
def clear_changes(self) -> Self:
|
||||
return replace(self, _events=())
|
||||
Reference in New Issue
Block a user