File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/allocation/service_layer Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22from typing import TYPE_CHECKING
3- from allocation .adapters import email
3+ from allocation .adapters import email , redis_eventpublisher
44from allocation .domain import commands , events , model
55from allocation .domain .model import OrderLine
66
@@ -49,6 +49,9 @@ def change_batch_quantity(
4949 uow .commit ()
5050
5151
52+ # pylint: disable=unused-argument
53+
54+
5255def send_out_of_stock_notification (
5356 event : events .OutOfStock ,
5457 uow : unit_of_work .AbstractUnitOfWork ,
@@ -57,3 +60,10 @@ def send_out_of_stock_notification(
5760 "stock@made.com" ,
5861 f"Out of stock for { event .sku } " ,
5962 )
63+
64+
65+ def publish_allocated_event (
66+ event : events .Allocated ,
67+ uow : unit_of_work .AbstractUnitOfWork ,
68+ ):
69+ redis_eventpublisher .publish ("line_allocated" , event )
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ def handle_command(
6363
6464
6565EVENT_HANDLERS = {
66+ events .Allocated : [handlers .publish_allocated_event ],
6667 events .OutOfStock : [handlers .send_out_of_stock_notification ],
6768} # type: Dict[Type[events.Event], List[Callable]]
6869
You can’t perform that action at this time.
0 commit comments