-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Currently there's a sort of circular logic flow where:
- EventBus.process_event() gets applicable handlers
- executes each handler and creates the
EventResult
placeholder + updates it after execution - EventResult relies on EventBus to execute the handler and update it, basically owns nothing.
Instead it should be something like:
- EventBus.process_event() uses method on
BaseEvent.create_pending_results(applicable_handlers)
- EventBus awaits each
EventResult.execute()
in turn, which handles auto-updating itself - EventResult.execute() handles executing the handler and storing the Exception, completed_at, status, etc. firing any signals needed
BaseEvent.check_if_all_handlers_completed()
checks list ofevent_results
and updates its own status + fires any signals neededEventBus.process_event()
checks the list ofevent_results
for any logging / its own logic
The idea is each model should have the methods needed to get
/set
/execute
itself. In theory it should be allowed to use just EventResult
objects in parallel without ever instantiating an Event
or EventBus
, etc. It should be allowed to just use BaseEvent
+ EventResult
without ever needing a bus, etc.
ideal layout:
logging.py # contains logging helpers
helpers.py # contains @retry logic, can only import from logging.py
event_handler.py # contains type overloads and base types for event handlers
event_result.py # contains EventResult model, can only import from event_handler.py
event.py # contains BaseEvent, can only import from event_result.py, event_handler.py, etc.
event_bus.py # contains EventBus, can only import from event.py, event_result.py, event_handler.py, etc.
circular imports in the other direction should only be allowed for type imports under if TYPE_CHECKING:
Metadata
Metadata
Assignees
Labels
No labels