File tree Expand file tree Collapse file tree
src/DurableFunctions.FSharp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ let printTime =
99 |> Activity.define " PrintTime"
1010
1111let workflow = orchestrator {
12- let! _ = Activity.call printTime DateTime.Now
12+ let! s = Activity.call printTime DateTime.Now
1313 do ! Orchestrator.delay ( TimeSpan.FromSeconds 5.0 )
14+ return if s.Contains " 00" then Stop else ContinueAsNew ()
1415}
1516
1617[<FunctionName( " PrintTime" ) >]
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ open System.Threading.Tasks
66open Microsoft.Azure .WebJobs
77open OrchestratorBuilder
88
9+ type EternalOrchestrationCommand < 'a > = Stop | ContinueAsNew of 'a
10+
911type Orchestrator = class
1012
1113 /// Runs a workflow which expects an input parameter by reading this parameter from
@@ -19,12 +21,24 @@ type Orchestrator = class
1921 let input = context.GetInput< 'a> ()
2022 workflow input context
2123
22- static member runEternal ( workflow : ContextTask < 'b > , context : DurableOrchestrationContext ) : Task < 'b > =
24+ static member runEternal ( workflow : ContextTask < EternalOrchestrationCommand < unit >> , context : DurableOrchestrationContext ) : Task =
2325 let task = workflow context
2426 task.ContinueWith (
25- fun ( t : Task < 'b >) ->
26- context.ContinueAsNew null
27- t.Result)
27+ fun ( t : Task < EternalOrchestrationCommand < unit >>) ->
28+ match t.Result with
29+ | ContinueAsNew () -> context.ContinueAsNew null
30+ | Stop -> ()
31+ )
32+
33+ static member runEternal ( workflow : 'a -> ContextTask < EternalOrchestrationCommand < 'a >>, context : DurableOrchestrationContext ) : Task =
34+ let input = context.GetInput< 'a> ()
35+ let task = workflow input context
36+ task.ContinueWith (
37+ fun ( t : Task < EternalOrchestrationCommand < 'a >>) ->
38+ match t.Result with
39+ | ContinueAsNew r -> context.ContinueAsNew r
40+ | Stop -> ()
41+ )
2842
2943 /// Returns a fixed value as a orchestrator.
3044 static member ret value ( _ : DurableOrchestrationContext ) =
You can’t perform that action at this time.
0 commit comments