-
Notifications
You must be signed in to change notification settings - Fork 54
[Durable] Custom orchestration status #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
examples/durable/DurableApp/CustomStatusOrchestrator/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "bindings": [ | ||
| { | ||
| "name": "Context", | ||
| "type": "orchestrationTrigger", | ||
| "direction": "in" | ||
| } | ||
| ] | ||
| } |
22 changes: 22 additions & 0 deletions
22
examples/durable/DurableApp/CustomStatusOrchestrator/run.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using namespace System.Net | ||
|
|
||
| param($Context) | ||
|
|
||
| Write-Host 'CustomStatusOrchestrator: started.' | ||
|
|
||
| $output = @() | ||
|
|
||
| Set-DurableCustomStatus -CustomStatus 'Processing Tokyo' | ||
| $output += Invoke-ActivityFunction -FunctionName 'SayHello' -Input 'Tokyo' | ||
|
|
||
| Set-DurableCustomStatus -CustomStatus @{ ProgressMessage = 'Processing Seattle'; Stage = 2 } | ||
| $output += Invoke-ActivityFunction -FunctionName 'SayHello' -Input 'Seattle' | ||
|
|
||
| Set-DurableCustomStatus -CustomStatus @('Processing London', 'Last stage') | ||
| $output += Invoke-ActivityFunction -FunctionName 'SayHello' -Input 'London' | ||
|
|
||
| Set-DurableCustomStatus 'Processing completed' | ||
|
|
||
| Write-Host 'CustomStatusOrchestrator: finished.' | ||
|
|
||
| $output |
24 changes: 24 additions & 0 deletions
24
examples/durable/DurableApp/CustomStatusStart/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "bindings": [ | ||
| { | ||
| "authLevel": "function", | ||
| "type": "httpTrigger", | ||
| "direction": "in", | ||
| "name": "Request", | ||
| "methods": [ | ||
| "get", | ||
| "post" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "http", | ||
| "direction": "out", | ||
| "name": "Response" | ||
| }, | ||
| { | ||
| "name": "starter", | ||
| "type": "durableClient", | ||
| "direction": "in" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using namespace System.Net | ||
|
|
||
| param($Request, $TriggerMetadata) | ||
|
|
||
| Write-Host 'CustomStatusStart started' | ||
|
|
||
| $InstanceId = Start-NewOrchestration -FunctionName 'CustomStatusOrchestrator' -InputObject 'Hello' | ||
| Write-Host "Started orchestration with ID = '$InstanceId'" | ||
|
|
||
| $Response = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId | ||
| Push-OutputBinding -Name Response -Value $Response | ||
|
|
||
| Write-Host 'CustomStatusStart completed' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #pragma warning disable 1591 // Missing XML comment for publicly visible type or member 'member' | ||
|
|
||
| namespace Microsoft.Azure.Functions.PowerShellWorker.Durable.Commands | ||
| { | ||
| using System.Collections; | ||
| using System.Management.Automation; | ||
|
|
||
| [Cmdlet("Set", "DurableCustomStatus")] | ||
| public class SetDurableCustomStatusCommand : PSCmdlet | ||
| { | ||
| [Parameter( | ||
| Mandatory = true, | ||
| Position = 0, | ||
| ValueFromPipeline = true)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would the use case be here for # 1)
'Processing Tokyo' | Set-DurableCustomStatus
# 2)
@{ ProgressMessage = 'Processing Seattle'; Stage = 2 } | Set-DurableCustomStatus
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly. |
||
| public object CustomStatus { get; set; } | ||
|
|
||
| protected override void EndProcessing() | ||
| { | ||
| var privateData = (Hashtable)MyInvocation.MyCommand.Module.PrivateData; | ||
| var context = (OrchestrationContext)privateData[SetFunctionInvocationContextCommand.ContextKey]; | ||
| context.CustomStatus = CustomStatus; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to assign a
Positionfor this parameter? I took a look at the other Durable cmdlets and this is the only one with a Positional parameter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to be very careful with adding positional parameters in general, but in this case I believe this is justified. The cmdlet takes just one parameter, and the purpose of this parameter is very obvious, so I want to allow users omit the parameter name:
Set-DurableCustomStatus "my status".I think we can carefully allow some positional parameters for some other durable-related cmdlets, but we can do this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good @AnatoliB, thank you.