This series is the journey of how can I research, implement, and deploy the demo application into Kubernetes with Dapr and Spin in place.
Experiment with WASM/WASI workload on k3d: How to run WebAssembly/WASI application (Spin) with Dapr on Kubernetes?
Source code of this series can be found at https://github.com/thangchung/dapr-labs/tree/main/polyglot.
To make this series cool and more practical works, we are going to build up the demo application on the coffee shop business domain (partially on this domain, mainly on submitting orders for buying drinks or food, sending requests to baristas or kitchen for fulfillment orders, then back to the user with a status). The reason why we choose this domain is because I love to drink coffee, and many people in my country too. And more importantly, this business domain is quite popular with everyone around the world.
Below is a little bit description of the coffee shop business domain from a technical POV:
- End-user comes to any coffee shop, for example, she wants to buy
a coffee back (3$)
anda croissant (3.25$)
so she asks to buy it. A man on the counter will receive the order (normally on a POS device), and submit this request into the system (our APIs). - On
counter-api
, we compose the HTTP request to call toproduct-api
to query all available items to check whether the items in the end-user order are valid or not. - If items are valid, then we create a new order and save it in the
counter-api
's data storage. - To make
counter-api
de-coupling withbarista-api
andkitchen-api
, we prefer to use Event-driven Architecture (EDA), and we can use EDA in both orchestrator and choreography communication styles. In this post, we maintain an ordering workflow (orchestrator) that will ensure that we submit 2 events: one forbarista_order_placed
inbarista-api
, and one forkitchen_order_placed
inkitchen-api
. - At the same time,
barista-api
andkitchen-api
parallel subscribe tobarista_order_placed
andkitchen_order_placed
events and process them. - The results of this process will be stored in the data storage in each
barista-api
andkitchen-api
. - Then in parallel,
barista-api
andkitchen-api
will publishbarista_order_updated
andkitchen_order_updated
events on each side to the message broker, following up withpub/sub pattern
in EDA (choreography style). -
counter-api
will subscribe tobarista_order_updated
andkitchen_order_updated
events from the message broker, and based on the result process, and updating the current order. - The end of this process is storing the updated order in the data storage (the previous step).
- The result will return back to the end-user (it might succeed or fail).
Notes: The end-user can query the specific order by on the identity that she gives for the counter.
The next post will be fun and interesting because we will deep dive into the technical parts to solve the business model above using modern technologies with WebAssembly, Docker container, Dapr, and Kubernetes.
Top comments (0)