-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEternal.fs
More file actions
33 lines (26 loc) · 1.11 KB
/
Eternal.fs
File metadata and controls
33 lines (26 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module samples.Eternal
open System
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Extensions.DurableTask
open DurableFunctions.FSharp
let printTime =
fun (d: DateTime) -> sprintf "Printing at %s!" (d.ToShortTimeString())
|> Activity.define "PrintTime"
let workflow = orchestrator {
let! (s: string) = Activity.call printTime DateTime.Now
do! Orchestrator.delay (TimeSpan.FromSeconds 5.0)
return if s.Contains "00" then Stop else ContinueAsNew ()
}
let workflowWithParam delay = orchestrator {
let! (s: string) = Activity.call printTime DateTime.Now
do! Orchestrator.delay (TimeSpan.FromSeconds delay)
return if s.Contains "00" then Stop else ContinueAsNew (delay + 1.)
}
[<FunctionName("PrintTime")>]
let PrintTime([<ActivityTrigger>] name) = printTime.run name
[<FunctionName("Eternal")>]
let Run ([<OrchestrationTrigger>] context: IDurableOrchestrationContext) =
Orchestrator.runEternal (workflow, context)
[<FunctionName("EternalWithParam")>]
let RunWithParam ([<OrchestrationTrigger>] context: IDurableOrchestrationContext) =
Orchestrator.runEternal (workflowWithParam, context)