Last active
April 8, 2020 19:05
Star
You must be signed in to star a gist
billing_created() handler subscribed to events:order in order_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def billing_created(self, _item): | |
if _item.event_action != 'entity_created': | |
return | |
billing = json.loads(_item.event_data) | |
rsp = send_message('read-model', 'get_entity', {'name': 'order', 'id': billing['order_id']}) | |
order = rsp['result'] | |
if order['status'] != 'IN_STOCK': | |
return | |
order['status'] = 'CLEARED' | |
self.event_store.publish('order', create_event('entity_updated', order)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This event handler is subscribed to
billing
events.02
guard for the correct event05
parse event topic, i.e.billing
06
getorder
forbilling
fromread model
08
guard for the correct state11
set new order status12
publish updated event