Skip to content

Instantly share code, notes, and snippets.

@geomagilles
Last active October 13, 2017 10:03
Show Gist options
  • Save geomagilles/7536a0c5c4d53e1811b6b0f9945709ee to your computer and use it in GitHub Desktop.
Save geomagilles/7536a0c5c4d53e1811b6b0f9945709ee to your computer and use it in GitHub Desktop.
Python example of workflow implementation using Zenaton
class OrderWorkflow(Workflow):
def __init__(self, item, address):
self.item = item
self.address = address
def handle(self):
self.execute(PrepareOrder(self.item))
event = self.execute(Wait(OrderPreparedEvent))
self.execute(SendOrder(event.id, self.item, self.address))
def on_event(self, event):
if isinstance(event, AddressUpdatedEvent):
self.address = event.address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment