File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/allocation/service_layer Expand file tree Collapse file tree 2 files changed +10
-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
66if TYPE_CHECKING :
@@ -47,10 +47,18 @@ def change_batch_quantity(
4747 uow .commit ()
4848
4949
50+ #pylint: disable=unused-argument
51+
5052def send_out_of_stock_notification (
5153 event : events .OutOfStock , uow : unit_of_work .AbstractUnitOfWork ,
5254):
5355 email .send (
5456 'stock@made.com' ,
5557 f'Out of stock for { event .sku } ' ,
5658 )
59+
60+
61+ def publish_allocated_event (
62+ event : events .Allocated , uow : unit_of_work .AbstractUnitOfWork ,
63+ ):
64+ redis_eventpublisher .publish ('line_allocated' , event )
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def handle_command(
6060
6161
6262EVENT_HANDLERS = {
63+ events .Allocated : [handlers .publish_allocated_event ],
6364 events .OutOfStock : [handlers .send_out_of_stock_notification ],
6465} # type: Dict[Type[events.Event], List[Callable]]
6566
You can’t perform that action at this time.
0 commit comments