Skip to content

Commit c31d765

Browse files
committed
subhandler for events [handle_event]
1 parent 6157d48 commit c31d765

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/allocation/service_layer/messagebus.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ def handle(
3131
return results
3232

3333

34+
def handle_event(
35+
event: events.Event,
36+
queue: List[Message],
37+
uow: unit_of_work.AbstractUnitOfWork,
38+
):
39+
for handler in EVENT_HANDLERS[type(event)]:
40+
try:
41+
logger.debug("handling event %s with handler %s", event, handler)
42+
handler(event, uow=uow)
43+
queue.extend(uow.collect_new_events())
44+
except Exception:
45+
logger.exception("Exception handling event %s", event)
46+
continue
47+
48+
3449
HANDLERS = {
3550
events.BatchCreated: [handlers.add_batch],
3651
events.BatchQuantityChanged: [handlers.change_batch_quantity],

0 commit comments

Comments
 (0)