mirror of https://github.com/dapr/quickstarts.git
Adding in flush statements to prints for workflow example (#873)
* Adding in flush statements to prints for workflow example Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Reverting other changes Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * makiong dapr run commands align in wf readme Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Updating componnents path to resources path Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> --------- Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
This commit is contained in:
parent
749013825b
commit
fff44b0383
|
|
@ -42,7 +42,7 @@ sleep: 15
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd ./order-processor
|
cd ./order-processor
|
||||||
dapr run --app-id order-processor --components-path ../../../components/ -- python3 app.py
|
dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- END_STEP -->
|
<!-- END_STEP -->
|
||||||
|
|
@ -81,7 +81,7 @@ For a more detailed view of the workflow activities (duration, progress etc.), t
|
||||||
|
|
||||||
### What happened?
|
### What happened?
|
||||||
|
|
||||||
When you ran `dapr run --app-id order-processor --app-protocol grpc --dapr-grpc-port 4001 --components-path ../../../components/ --placement-host-address localhost:50005 -- python3 app.py`
|
When you ran `dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py`
|
||||||
|
|
||||||
1. First the user inputs an order for 11 cars into the concole app.
|
1. First the user inputs an order for 11 cars into the concole app.
|
||||||
2. A unique order ID for the workflow is generated (in the above example, `b903d749cd814e099f06ebf4a56a2f90`) and the workflow is scheduled.
|
2. A unique order ID for the workflow is generated (in the above example, `b903d749cd814e099f06ebf4a56a2f90`) and the workflow is scheduled.
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ default_item_name = "cars"
|
||||||
|
|
||||||
class WorkflowConsoleApp:
|
class WorkflowConsoleApp:
|
||||||
def main(self):
|
def main(self):
|
||||||
print("*** Welcome to the Dapr Workflow console app sample!")
|
print("*** Welcome to the Dapr Workflow console app sample!", flush=True)
|
||||||
print("*** Using this app, you can place orders that start workflows.")
|
print("*** Using this app, you can place orders that start workflows.", flush=True)
|
||||||
# Wait for the sidecar to become available
|
# Wait for the sidecar to become available
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
|
||||||
|
|
@ -39,13 +39,13 @@ class WorkflowConsoleApp:
|
||||||
|
|
||||||
self.restock_inventory(daprClient, baseInventory)
|
self.restock_inventory(daprClient, baseInventory)
|
||||||
|
|
||||||
print("==========Begin the purchase of item:==========")
|
print("==========Begin the purchase of item:==========", flush=True)
|
||||||
item_name = default_item_name
|
item_name = default_item_name
|
||||||
order_quantity = 11
|
order_quantity = 11
|
||||||
|
|
||||||
total_cost = int(order_quantity) * baseInventory[item_name].per_item_cost
|
total_cost = int(order_quantity) * baseInventory[item_name].per_item_cost
|
||||||
order = OrderPayload(item_name=item_name, quantity=int(order_quantity), total_cost=total_cost)
|
order = OrderPayload(item_name=item_name, quantity=int(order_quantity), total_cost=total_cost)
|
||||||
print(f'Starting order workflow, purchasing {order_quantity} of {item_name}')
|
print(f'Starting order workflow, purchasing {order_quantity} of {item_name}', flush=True)
|
||||||
start_resp = daprClient.start_workflow(workflow_component=workflow_component,
|
start_resp = daprClient.start_workflow(workflow_component=workflow_component,
|
||||||
workflow_name=workflow_name,
|
workflow_name=workflow_name,
|
||||||
input=order)
|
input=order)
|
||||||
|
|
@ -89,7 +89,7 @@ class WorkflowConsoleApp:
|
||||||
elif state.runtime_status == "Completed" or\
|
elif state.runtime_status == "Completed" or\
|
||||||
state.runtime_status == "Failed" or\
|
state.runtime_status == "Failed" or\
|
||||||
state.runtime_status == "Terminated":
|
state.runtime_status == "Terminated":
|
||||||
print(f'Workflow completed! Result: {state.runtime_status}')
|
print(f'Workflow completed! Result: {state.runtime_status}', flush=True)
|
||||||
break
|
break
|
||||||
if time_delta.total_seconds() >= 10:
|
if time_delta.total_seconds() >= 10:
|
||||||
state = daprClient.get_workflow(instance_id=_id, workflow_component=workflow_component)
|
state = daprClient.get_workflow(instance_id=_id, workflow_component=workflow_component)
|
||||||
|
|
@ -101,7 +101,7 @@ class WorkflowConsoleApp:
|
||||||
approval_seeked = True
|
approval_seeked = True
|
||||||
threading.Thread(target=prompt_for_approval(daprClient), daemon=True).start()
|
threading.Thread(target=prompt_for_approval(daprClient), daemon=True).start()
|
||||||
|
|
||||||
print("Purchase of item is ", state.runtime_status)
|
print("Purchase of item is ", state.runtime_status, flush=True)
|
||||||
|
|
||||||
def restock_inventory(self, daprClient: DaprClient, baseInventory):
|
def restock_inventory(self, daprClient: DaprClient, baseInventory):
|
||||||
for key, item in baseInventory.items():
|
for key, item in baseInventory.items():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue