Improved workflows example program and added in statestore functionality.#1020
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1020 +/- ##
=======================================
Coverage 69.45% 69.45%
=======================================
Files 162 162
Lines 5432 5432
Branches 585 585
=======================================
Hits 3773 3773
Misses 1519 1519
Partials 140 140
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
cgillum
left a comment
There was a problem hiding this comment.
Nice work on this! Here's my feedback. Mostly nit-picky stuff.
| using WorkflowWebApp.Workflows; | ||
| using WorkflowWebApp.Models; | ||
| using JsonOptions = Microsoft.AspNetCore.Http.Json.JsonOptions; | ||
| using Dapr.Client; |
There was a problem hiding this comment.
nit: Let's sort the using statements alphabetically.
| string orderId = Guid.NewGuid().ToString()[..8]; | ||
| // All the necessary inputs (with workflow options being optional) | ||
| string workflowComponent = "dapr"; | ||
| string workflowName = "OrderProcessingWorkflow"; |
There was a problem hiding this comment.
let's do nameof(OrderProcessingWorkflow) instead of hardcoding the name. That way the program won't break if someone renames the workflow class.
| // All the necessary inputs (with workflow options being optional) | ||
| string workflowComponent = "dapr"; | ||
| string workflowName = "OrderProcessingWorkflow"; | ||
| object input = orderInfo; |
There was a problem hiding this comment.
nit: remove this and pass orderInfo as the input directly.
| string workflowComponent = "dapr"; | ||
| string workflowName = "OrderProcessingWorkflow"; | ||
| object input = orderInfo; | ||
| Dictionary<string, string> workflowOptions = new Dictionary<string, string>(); |
There was a problem hiding this comment.
Is workflowOptions required or can we just pass null below since we don't add any options?
| string workflowName = "OrderProcessingWorkflow"; | ||
| object input = orderInfo; | ||
| Dictionary<string, string> workflowOptions = new Dictionary<string, string>(); | ||
| CancellationToken cts = new CancellationToken(); |
There was a problem hiding this comment.
Let's remove this and use CancellationToken.None below.
| this.logger.LogInformation($"There are now: {original.Quantity} {original.Name} left in stock"); | ||
|
|
||
| this.logger.LogInformation( | ||
| "OrderID '{requestId}' processed successfully", |
There was a problem hiding this comment.
I'd remove this log statement. This activity is only concerned with managing inventory and shouldn't make any assumptions about the status of the order.
| { | ||
| readonly ILogger logger; | ||
| readonly DaprClient client; | ||
| private static readonly string storeName = "statestore"; |
There was a problem hiding this comment.
Looks like this is defined in two places. Let's put it somewhere more global to reduce the duplication.
| if (original == null) | ||
| { | ||
| // Not enough paperclips. | ||
| return new InventoryResult(false, original, originalETag); |
There was a problem hiding this comment.
Instead of original and originalETag here, just do null, null. The intent is otherwise confusing to the reader.
There was a problem hiding this comment.
"original" is still needed since it is the response from the statestore. If there are no items, we need to check for it. Furthermore, we use 'original' to see the quantity of items as well as logging. I think we should just rename 'original' to 'orderResponse' or something along those lines
|
|
||
| The application will listen for HTTP requests at `http://localhost:10080`. | ||
|
|
||
| This workflow example utilizes a redis statestore. In order to retrieve items from this statestore, an HTTP command must first be sent down to restock the inventory: |
There was a problem hiding this comment.
I think you meant, "In order to populate items into the state store..."
| On Windows (PowerShell): | ||
|
|
||
| ```powershell | ||
| curl -i -X POST http://localhost:10080/reset ` |
There was a problem hiding this comment.
This command actually isn't correct for PowerShell. The trailing ` means you're entering a multi-line command, which is not the case.
In any case, the command is exactly the same for both bash and powershell, so no need to distinguish them here.
| } | ||
|
|
||
| this.logger.LogInformation( | ||
| "There are: {requestId}, {name} available for purchase", |
There was a problem hiding this comment.
question/nit: is the requestId the remaining items in stock? I wasn't sure, but the sentence sounds more correct to me without punctuation.
| "There are: {requestId}, {name} available for purchase", | |
| "There are {requestId} {name} available for purchase", |
There was a problem hiding this comment.
I'd rather prefer to have the shell scripts commands ready to run (for lazy users whose will copy/paste before going through the text, like me [sometimes]).
I can see two options:
- Generate a random ID and print after the command get executed
randomId=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 50 | head -n 1)
curl -i -X POST http://localhost:3500/v1.0-alpha1/workflows/dapr/OrderProcessingWorkflow/$randomId/start \
-H "Content-Type: application/json" \
-d '{ "input" : {"Name": "Paperclips", "TotalCost": 99.95, "Quantity": 1}}'This command works on Linix OSs
Then ask the user to copy out the instance_id from the curl output.
- Auto-generated workflow ids?
Given the circumstances (time-wise), I guess this option is not feasible cause it might require new APIs, etc.
There was a problem hiding this comment.
You could also, assign the randomId to a variable to be reusable later
There was a problem hiding this comment.
I updated the example to use a hardcoded ID. That seemed like an overall simpler solution. :)
And yes, we need to support auto-generated IDs. I'm planning to open a bug for v1.11 to support this.
There was a problem hiding this comment.
Sry, my powershell knowledge isn't sufficient to suggest any specific solution for random string than googling it: https://devblogs.microsoft.com/scripting/generate-random-letters-with-powershell/
There was a problem hiding this comment.
I switched to using harcoded IDs. It's what I use for my manual testing anyways, and the IDs can be reused after the workflow completes.
There was a problem hiding this comment.
The other think is that my traceparent is not working as well (returning a bunch of zero) is that correct?
I guess you have zipkin configured while I don't. So you might have to disable since it was not mentioned?
There was a problem hiding this comment.
I’m planning to open a bug to track the missing Location header from the StartWorkflow API. Previously, we were returning it from the custom web API. For now, we should remove this from the directions.
There was a problem hiding this comment.
I removed the Location header from the response example and removed mention of it from the text. I also went ahead and removed the Traceparent headers to avoid distracting the user from the primary objective of this example.
There was a problem hiding this comment.
issue: the other properties uses _ and this one is using a capital letter, but since this payloads comes from runtime I guess there's no alternative than creating a issue to change this later (v1.11).
this will be seen as a breaking change but since wf is in alpha we are fine.
There was a problem hiding this comment.
We can change "WFInfo" in v1.11 since it requires a change to the components-contrib code.
There was a problem hiding this comment.
should we fulfill the custom_status field with something meaningful ?
There was a problem hiding this comment.
I think we can consider this for a future update.
There was a problem hiding this comment.
Is it valuable to supply the documentation link for individuals without a configured Zipkin?
There was a problem hiding this comment.
Do we need to return something <object>? Can we just return a Task ?
There was a problem hiding this comment.
The base class currently requires a Task<T>, but we can look into providing a Task option in a future update.
There was a problem hiding this comment.
Is 1 second always sufficient?
There was a problem hiding this comment.
It's just for vanity purposes, but so far it's been sufficient each time I tried.
There was a problem hiding this comment.
do we need to mention this here?
There was a problem hiding this comment.
I figured that folks probably should rely on this pattern moving forward, and that it serves as a heads-up.
|
I would also update
|
There was a problem hiding this comment.
I think we can consider this for a future update.
There was a problem hiding this comment.
The base class currently requires a Task<T>, but we can look into providing a Task option in a future update.
There was a problem hiding this comment.
It's just for vanity purposes, but so far it's been sufficient each time I tried.
There was a problem hiding this comment.
I figured that folks probably should rely on this pattern moving forward, and that it serves as a heads-up.
Initial work for workflows DotNET SDK Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
…ionality Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
* Update DurableTask SDK dependency to get ARM64 compatibility Signed-off-by: Chris Gillum <cgillum@microsoft.com> * Fix issue with gRPC address override behavior Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
- Replaced DaprClient with WorkflowEngineClient - Removed unused etag logic - Fixed incorrect usage of certain model types - Cleaned up logs and console output - Simplified program loop - Cleaned up console output and added some coloring - Added error handling in the console interactions - Various other tweaks/simplifications/enhancements Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
* add workflows to client page Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com>
halspang
left a comment
There was a problem hiding this comment.
Just a few nitpicks. Primarily around the placement of using statements. You had it in a few files where I didn't comment but generally all usings should be outside of the namespace.
There was a problem hiding this comment.
Nit: using should be above the namespace.
There was a problem hiding this comment.
The <NoWarn>612,618</NoWarn> disables the "obsolete" warnings that we get when using the DaprClient methods. I'm actually not sure that these are needed, though, now that we've reverted to using WorkflowEngineClient in this initial release of the sample.
There was a problem hiding this comment.
These are to supress the warnings that come from the fact that we are using functions that are still in alpha.
944f482 to
35c1f1d
Compare
…ity. (dapr#1020) * Workflow Management - Initial Methods (dapr#1003) Initial work for workflows DotNET SDK Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Beefed up the workflows example program and added in statestore functionality Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Addressing a bunch of review comments Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Updates to readme and demo for workflows Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Changed webapp to console app Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Update DurableTask SDK dependency to get ARM64 compatibility (dapr#1024) * Update DurableTask SDK dependency to get ARM64 compatibility Signed-off-by: Chris Gillum <cgillum@microsoft.com> * Fix issue with gRPC address override behavior Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Remove Web APIs and web dependencies Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Renaming WorkflowWebApp to WorkflowConsoleApp Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Various updates to the sample app - Replaced DaprClient with WorkflowEngineClient - Removed unused etag logic - Fixed incorrect usage of certain model types - Cleaned up logs and console output - Simplified program loop - Cleaned up console output and added some coloring - Added error handling in the console interactions - Various other tweaks/simplifications/enhancements Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Updates to README and demo http commands Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Make README copy/paste-able and some other minor tweaks Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Adding in Paul's devcontainer work Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * More README touch-ups Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * [docs] Add workflows to .NET client doc (dapr#1019) * add workflows to client page Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com> Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Updating workflows readme and example Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * Fixing README for letting users know which .NET is needed Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> * moving using statements above the namespace Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> --------- Signed-off-by: Ryan Lettieri <ryanLettieri@microsoft.com> Signed-off-by: Chris Gillum <cgillum@microsoft.com> Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com> Co-authored-by: Ryan Lettieri <ryanLettieri@microsoft.com> Co-authored-by: Chris Gillum <cgillum@microsoft.com> Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com>

…ionality
Signed-off-by: Ryan Lettieri ryanLettieri@microsoft.com
Description
Please explain the changes you've made
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: