mirror of https://github.com/dapr/quickstarts.git
* update dapr runtime to use v1.12.0-rc.1 Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * update to latest rc for runtime and cli Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * try sleeping Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * pin redis version Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * rm sleep Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * rm deprecated unsubscribe call Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * Update configuration/go/sdk/order-processor/app.go Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Signed-off-by: Cassie Coyle <cassie.i.coyle@gmail.com> * Statemanagement multiapp run Signed-off-by: rabollin <rabollin@microsoft.com> * message sequence Signed-off-by: rabollin <rabollin@microsoft.com> * message sequence Signed-off-by: rabollin <rabollin@microsoft.com> * Multi-run support for workflow Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Removing component folder from run file to match readme Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * aligning state store names on `statestore` Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Adding multi-app run for python and C# Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * pr comments Signed-off-by: rabollin <rabollin@microsoft.com> * pr comments Signed-off-by: rabollin <rabollin@microsoft.com> * sleep value increase Signed-off-by: rabollin <rabollin@microsoft.com> * sleep seconds increase Signed-off-by: rabollin <rabollin@microsoft.com> * Result correction Signed-off-by: rabollin <rabollin@microsoft.com> * Result correction Signed-off-by: rabollin <rabollin@microsoft.com> * java sdk dapr run output format fixing Signed-off-by: rabollin <rabollin@microsoft.com> * Syncing Release 1.12 with master and multi-run changes (#936) * Add holopin.yml config (#923) Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> * Updating Readme's to default to `dapr run -f .` (#874) * Updating Invoke readme in C# to favor dapr run -f Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> * Adding back single app run steps and tests, but to the end. Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Update service_invocation/csharp/http/README.md Co-authored-by: Mark Fussell <markfussell@gmail.com> Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> * Updated and hardened test Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Invoke * and partial PubSub with multi-run files & readmes & tests Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Multi run done for Pubsub C#, Python and Node (http, sdk) Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> * Added Pubsub support for Go, Java Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> * updating readmes with correct appid Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> * Updating tests for PubSub and Service invoke to Paas with multiapp run Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * More fine tuning of pubsub tests (timeouts, step ends) Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Fixing Python FastAPI and C# Pubsub tests Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> --------- Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Co-authored-by: Mark Fussell <markfussell@gmail.com> * Patching tests to pass (C# timing, Python uvicorn) (#933) Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> --------- Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> Co-authored-by: Marc Duiker <marcduiker@users.noreply.github.com> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Co-authored-by: Mark Fussell <markfussell@gmail.com> * Fixing MMD tests with tweaks Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * setting version for kafka (#939) * fixing version for kafka Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> * validate data with some initial values instead of larger Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> --------- Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> * Updating test env to Dapr runtime 1.12 RC4 and CLI RC2 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Update README.md Fixing typo. should be singular Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> * Update README.md Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> * add java workflow quickstart Signed-off-by: Sky Ao <aoxiaojian@gmail.com> * Updating runtime for tests to RC5 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Fixes port 6003 conflict between Go Pub-sub and Go bindings. Timing issue Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * add hello-kubernetes multi-app run k8s template Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> * address review comments. Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> * update cli to rc.4 (#943) * update cli to rc.3 Signed-off-by: Cassandra Coyle <cassie@diagrid.io> * update cli to rc.4 Signed-off-by: Cassandra Coyle <cassie@diagrid.io> --------- Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: Cassie Coyle <cassie.i.coyle@gmail.com> * Update CLI to rc4 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Updating .NET SDK to 1.12.* Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Dapr Golang SDK update to v1.9.0-rc-1 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Javascript SDK to 3.1.2 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Release 1.12 (#945) * Dapr Golang SDK update to v1.9.0-rc-1 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Javascript SDK to 3.1.2 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> --------- Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Java SDK update to <version>1.10.0-rc-1</version> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Updated Java SDK to RC, and donated multi-app-run support too :) Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> * Updating tests to use dapr/dapr 1.12.0-rc.6 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> * sdk version changes Signed-off-by: rabollin <rabollin@microsoft.com> * CLI and Runtime version changes Signed-off-by: rabollin <rabollin@microsoft.com> * go.sum refresh Signed-off-by: rabollin <rabollin@microsoft.com> * Updating with js-sdk 3.2.0 Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> --------- Signed-off-by: Cassandra Coyle <cassie@diagrid.io> Signed-off-by: Cassie Coyle <cassie.i.coyle@gmail.com> Signed-off-by: rabollin <rabollin@microsoft.com> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com> Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com> Signed-off-by: Sky Ao <aoxiaojian@gmail.com> Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: Cassandra Coyle <cassie@diagrid.io> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Co-authored-by: rabollin <rabollin@microsoft.com> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan> Co-authored-by: Marc Duiker <marcduiker@users.noreply.github.com> Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local> Co-authored-by: Mark Fussell <markfussell@gmail.com> Co-authored-by: Pravin Pushkar <ppushkar@microsoft.com> Co-authored-by: Sky Ao <aoxiaojian@gmail.com> Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> |
||
---|---|---|
.. | ||
img | ||
order-processor | ||
README.md | ||
dapr.yaml | ||
makefile |
README.md
Dapr workflows
In this quickstart, you'll create a simple console application to demonstrate Dapr's workflow programming model and the workflow management API. The console app starts and manages an order processing workflow.
This quickstart includes one project:
- Python console app
order-processor
The quickstart contains 1 workflow (order_processing_workflow) which simulates purchasing items from a store, and 5 unique activities within the workflow. These 5 activities are as follows:
- notify_activity: This activity utilizes a logger to print out messages throughout the workflow. These messages notify the user when there is insufficient inventory, their payment couldn't be processed, and more.
- process_payment_activity: This activity is responsible for processing and authorizing the payment.
- verify_inventory_activity: This activity checks the state store to ensure that there is enough inventory present for purchase.
- update_inventory_activity: This activity removes the requested items from the state store and updates the store with the new remaining inventory value.
- requst_approval_activity: This activity seeks approval from Manager, if payment is greater than 50000 USD.
Run the order processor workflow
- Open a new terminal window and navigate to
order-processor
directory:
cd ./order-processor
pip3 install -r requirements.txt
cd ..
- Run the console app with Dapr:
dapr run -f .
- Expected output
==========Begin the purchase of item:==========
To restock items, type 'restock'.
To exit workflow console app, type 'exit'.
Enter the name of one of the following items to order: paperclip, cars, computers: cars
How many cars would you like to purchase? 10
Starting order workflow, purchasing 10 of cars
INFO:NotifyActivity:Received order b903d749cd814e099f06ebf4a56a2f90 for 10 cars at $150000 !
INFO:VerifyInventoryActivity:Verifying inventory for order b903d749cd814e099f06ebf4a56a2f90 of 10 cars
INFO:VerifyInventoryActivity:There are 100 Cars available for purchase
INFO:RequestApprovalActivity:Requesting approval for payment of 150000 USD for 10 cars
(ID = b903d749cd814e099f06ebf4a56a2f90) requires approval. Approve? [Y/N] y
INFO:NotifyActivity:Payment for order b903d749cd814e099f06ebf4a56a2f90 has been approved!
INFO:ProcessPaymentActivity:Processing payment: b903d749cd814e099f06ebf4a56a2f90 for 10 cars at 150000 USD
INFO:ProcessPaymentActivity:Payment for request ID b903d749cd814e099f06ebf4a56a2f90 processed successfully
INFO:UpdateInventoryActivity:Checking inventory for order b903d749cd814e099f06ebf4a56a2f90 for 10 cars
INFO:UpdateInventoryActivity:There are now 90 cars left in stock
INFO:NotifyActivity:Order b903d749cd814e099f06ebf4a56a2f90 has completed!
Workflow completed! Result: Completed
Purchase of item is Completed
- Stop Dapr workflow with CTRL-C or:
dapr stop -f .
View workflow output with Zipkin
For a more detailed view of the workflow activities (duration, progress etc.), try using Zipkin.
- View Traces in Zipkin UI - In your browser go to http://localhost:9411 to view the workflow trace spans in the Zipkin web UI. The order-processor workflow should be viewable with the following output in the Zipkin web UI. Note: the openzipkin/zipkin docker container is launched on running
dapr init
.
What happened?
When you ran dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py
- First the user inputs an order for 10 cars into the concole app.
- A unique order ID for the workflow is generated (in the above example,
b903d749cd814e099f06ebf4a56a2f90
) and the workflow is scheduled. - The
NotifyActivity
workflow activity sends a notification saying an order for 10 cars has been received. - The
VerifyInventoryActivity
workflow activity checks the inventory data, determines if you can supply the ordered item, and responds with the number of cars in stock. - The
RequestApprovalActivity
workflow activity is triggered due to buisness logic for orders exceeding $50k and user is prompted to manually approve the purchase before continuing order. - The workflow starts and notifies you of its status.
- The
ProcessPaymentActivity
workflow activity begins processing payment for orderb903d749cd814e099f06ebf4a56a2f90
and confirms if successful. - The
UpdateInventoryActivity
workflow activity updates the inventory with the current available cars after the order has been processed. - The
NotifyActivity
workflow activity sends a notification saying that orderb903d749cd814e099f06ebf4a56a2f90
has completed. - The workflow terminates as completed.