Skip to content

Commit

Permalink
events, django signal
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Jul 9, 2021
1 parent 028b84f commit 359abfd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."""

__version__ = "0.1.12"
__version__ = "0.2.1"

from abc import ABC

Expand Down
4 changes: 2 additions & 2 deletions fractal/contrib/django/projectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def project(self, id: str, event: Type[SendingEvent]):
message = Message(
id=id,
occurred_on=datetime.datetime.now(tz=datetime.timezone.utc),
event_type=event.__class__.__name__,
event=event,
event=event.__class__.__name__,
data=event,
object_id=str(event.object_id),
)
fractal_event_signal.send(sender=self.__class__, message=message)
5 changes: 2 additions & 3 deletions fractal/core/event_sourcing/event_projector.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from abc import ABC, abstractmethod
from typing import Type

from fractal.core.event_sourcing.event import SendingEvent
from fractal.core.event_sourcing.event import BasicSendingEvent


class EventProjector(ABC):
@abstractmethod
def project(self, id: str, event: Type[SendingEvent]):
def project(self, id: str, event: BasicSendingEvent):
pass
6 changes: 3 additions & 3 deletions fractal/core/event_sourcing/event_publisher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from fractal.core.event_sourcing.event import Event
from fractal.core.event_sourcing.event import BasicSendingEvent
from fractal.core.event_sourcing.event_projector import EventProjector
from fractal.core.event_sourcing.event_stream import EventStream

Expand All @@ -9,7 +9,7 @@ class EventPublisher:
def __init__(self, projectors: List[EventProjector]):
self.projectors = projectors

def publish_event(self, event: Event):
def publish_event(self, event: BasicSendingEvent):
self._publish(
EventStream(
events=[
Expand All @@ -18,7 +18,7 @@ def publish_event(self, event: Event):
)
)

def publish_events(self, events: List[Event]):
def publish_events(self,events: List[BasicSendingEvent]):
self._publish(
EventStream(
events=events,
Expand Down

0 comments on commit 359abfd

Please sign in to comment.