Adding cancel to workflow example and updating api references to beta (#1194)

Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
This commit is contained in:
Ryan Lettieri 2023-11-29 15:39:56 -07:00 committed by GitHub
parent e8204dca45
commit 10ef81873b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 12 deletions

View File

@ -83,7 +83,7 @@ Run the following command to start a workflow.
{{% codetab %}} {{% codetab %}}
```bash ```bash
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 \ curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}' -d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
``` ```
@ -93,7 +93,7 @@ curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessing
{{% codetab %}} {{% codetab %}}
```powershell ```powershell
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 ` curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=12345678 `
-H "Content-Type: application/json" ` -H "Content-Type: application/json" `
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}' -d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
``` ```
@ -111,7 +111,7 @@ If successful, you should see a response like the following:
Send an HTTP request to get the status of the workflow that was started: Send an HTTP request to get the status of the workflow that was started:
```bash ```bash
curl -i -X GET http://localhost:3500/v1.0-alpha1/workflows/dapr/12345678 curl -i -X GET http://localhost:3500/v1.0-beta1/workflows/dapr/12345678
``` ```
The workflow is designed to take several seconds to complete. If the workflow hasn't completed when you issue the HTTP request, you'll see the following JSON response (formatted for readability) with workflow status as `RUNNING`: The workflow is designed to take several seconds to complete. If the workflow hasn't completed when you issue the HTTP request, you'll see the following JSON response (formatted for readability) with workflow status as `RUNNING`:

View File

@ -61,7 +61,7 @@ For the workflow API option, two identical `curl` commands are shown, one for Li
Make note of the "1234" in the commands below. This represents the unique identifier for the workflow run and can be replaced with any identifier of your choosing. Make note of the "1234" in the commands below. This represents the unique identifier for the workflow run and can be replaced with any identifier of your choosing.
```bash ```bash
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 \ curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}' -d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
``` ```
@ -69,7 +69,7 @@ curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessing
On Windows (PowerShell): On Windows (PowerShell):
```powershell ```powershell
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 ` curl -i -X POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=1234 `
-H "Content-Type: application/json" ` -H "Content-Type: application/json" `
-d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}' -d '{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}'
``` ```
@ -83,7 +83,7 @@ If successful, you should see a response like the following:
Next, send an HTTP request to get the status of the workflow that was started: Next, send an HTTP request to get the status of the workflow that was started:
```bash ```bash
curl -i -X GET http://localhost:3500/v1.0-alpha1/workflows/dapr/1234 curl -i -X GET http://localhost:3500/v1.0-beta1/workflows/dapr/1234
``` ```
The workflow is designed to take several seconds to complete. If the workflow hasn't completed yet when you issue the previous command, you should see the following JSON response (formatted for readability): The workflow is designed to take several seconds to complete. If the workflow hasn't completed yet when you issue the previous command, you should see the following JSON response (formatted for readability):
@ -132,4 +132,4 @@ info: WorkflowConsoleApp.Activities.NotifyActivity[0]
Order 1234 processed successfully! Order 1234 processed successfully!
``` ```
If you have Zipkin configured for Dapr locally on your machine, then you can view the workflow trace spans in the Zipkin web UI (typically at http://localhost:9411/zipkin/). If you have Zipkin configured for Dapr locally on your machine, then you can view the workflow trace spans in the Zipkin web UI (typically at http://localhost:9411/zipkin/).

View File

@ -81,7 +81,14 @@ await RestockInventory(daprClient, baseInventory);
// Start the input loop // Start the input loop
using (daprClient) using (daprClient)
{ {
while (true) bool quit = false;
Console.CancelKeyPress += delegate
{
quit = true;
Console.WriteLine("Shutting down the example.");
};
while (!quit)
{ {
// Get the name of the item to order and make sure we have inventory // Get the name of the item to order and make sure we have inventory
string items = string.Join(", ", baseInventory.Select(i => i.Name)); string items = string.Join(", ", baseInventory.Select(i => i.Name));

View File

@ -1,17 +1,17 @@
### Start order processing workflow - replace xxx with any id you like ### Start order processing workflow - replace xxx with any id you like
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
Content-Type: application/json Content-Type: application/json
{"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1} {"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}
### Start order processing workflow - replace xxx with any id you like ### Start order processing workflow - replace xxx with any id you like
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx POST http://localhost:3500/v1.0-beta1/workflows/dapr/OrderProcessingWorkflow/start?instanceID=xxx
Content-Type: application/json Content-Type: application/json
{"Name": "Cars", "TotalCost": 10000, "Quantity": 30} {"Name": "Cars", "TotalCost": 10000, "Quantity": 30}
### Query dapr sidecar - replace xxx with id from the workflow you've created above ### Query dapr sidecar - replace xxx with id from the workflow you've created above
GET http://localhost:3500/v1.0-alpha1/workflows/dapr/xxx GET http://localhost:3500/v1.0-beta1/workflows/dapr/xxx
### Terminate the workflow - replace xxx with id from the workflow you've created above ### Terminate the workflow - replace xxx with id from the workflow you've created above
POST http://localhost:3500/v1.0-alpha1/workflows/dapr/xxx/terminate POST http://localhost:3500/v1.0-beta1/workflows/dapr/xxx/terminate