Skip to content

Commit 7263d99

Browse files
committed
new helpers to update read model [redis_readmodel_client]
1 parent 02b1ae5 commit 7263d99

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/allocation/adapters/redis_eventpublisher.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@
1414
def publish(channel, event: events.Event):
1515
logging.debug('publishing: channel=%s, event=%s', channel, event)
1616
r.publish(channel, json.dumps(asdict(event)))
17+
18+
19+
def update_readmodel(orderid, sku, batchref):
20+
r.hset(orderid, sku, batchref)
21+
22+
23+
def get_readmodel(orderid):
24+
return r.hgetall(orderid)

src/allocation/entrypoints/redis_eventconsumer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ def handle_change_batch_quantity(m):
2727
cmd = commands.ChangeBatchQuantity(ref=data['batchref'], qty=data['qty'])
2828
messagebus.handle(cmd, uow=unit_of_work.SqlAlchemyUnitOfWork())
2929

30+
3031
if __name__ == '__main__':
3132
main()

0 commit comments

Comments
 (0)