Skip to content

Commit aef9c70

Browse files
committed
Initial commit
1 parent 21a8f82 commit aef9c70

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
build_output
2+
Directory.Build.props
3+
*.suo
4+
*.user
5+
*.dotCover
6+
7+
8+
bin
9+
obj
10+
_ReSharper*
11+
12+
*.psess
13+
*.vspx
14+
15+
*wpftmp.csproj
16+
*.csproj.user
17+
*.resharper.user
18+
*.resharper
19+
*.ReSharper
20+
*.cache
21+
*.g.cs
22+
*~
23+
*.swp
24+
*.bak
25+
*.orig
26+
27+
*.userprefs
28+
*.log.txt
29+
30+
.fake
31+
packages
32+
TestResults
33+
run
34+
35+
.vs
36+
paket-files/
37+
.paket/paket.bootstrapper.exe
38+
39+
.idea/
40+
41+
deploy/
42+
43+
BenchmarkDotNet.Artifacts/
44+
45+
# Ionide (cross platform F# VS Code tools) working folder
46+
.ionide/
47+
48+
### VS Code ###
49+
.vscode/*
50+
!.vscode/settings.json
51+
!.vscode/tasks.json
52+
!.vscode/launch.json
53+
!.vscode/extensions.json
54+
*.code-workspace

src/FSharp.DurableExtensions.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.6.33829.357
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.DurableExtensions", "FSharp.DurableExtensions\FSharp.DurableExtensions.fsproj", "{B67E280D-5781-4D96-A5B8-4A71755B8359}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B67E280D-5781-4D96-A5B8-4A71755B8359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B67E280D-5781-4D96-A5B8-4A71755B8359}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B67E280D-5781-4D96-A5B8-4A71755B8359}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B67E280D-5781-4D96-A5B8-4A71755B8359}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {7CBD21E6-59B7-4ED4-84AE-EF7C6ABB3D22}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="IDurableOrchestrationContext.fs" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.10.0" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module FSharp.DurableExtensions
2+
3+
open System.Threading.Tasks
4+
open Microsoft.FSharp.Quotations
5+
open Microsoft.Azure.WebJobs.Extensions.DurableTask
6+
7+
/// Extension methods for calling Azure Durable Activity Functions with strongly typed inputs and outputs.
8+
type IDurableOrchestrationContext with
9+
10+
/// Calls a function with no ActivityTrigger input.
11+
member ctx.CallActivity<'D1, 'Output> ([<ReflectedDefinition>] azureFn: Expr<'D1 -> Task<'Output>>, ?retry: RetryOptions) : Task<'Output> =
12+
let functionName =
13+
match azureFn with
14+
| DerivedPatterns.Lambdas(_, Patterns.Call(_,mi,_)) -> mi.Name
15+
| _ -> failwith "Invalid fn"
16+
17+
match retry with
18+
| Some opt ->
19+
ctx.CallActivityWithRetryAsync<'Output>(functionName, opt, null)
20+
| None ->
21+
ctx.CallActivityAsync<'Output>(functionName, null)
22+
23+
/// Calls a function with an ActivityTrigger input parameter and no dependency parameters.
24+
member ctx.CallActivity<'Input, 'Output> ([<ReflectedDefinition>] azureFn: Expr<'Input -> Task<'Output>>, req: 'Input, ?retry: RetryOptions) : Task<'Output> =
25+
let functionName =
26+
match azureFn with
27+
| DerivedPatterns.Lambdas(_, Patterns.Call(_,mi,_)) -> mi.Name
28+
| _ -> failwith "Invalid fn"
29+
30+
match retry with
31+
| Some opt ->
32+
ctx.CallActivityWithRetryAsync<'Output>(functionName, opt, req)
33+
| None ->
34+
ctx.CallActivityAsync<'Output>(functionName, req)
35+
36+
/// Calls a function with an ActivityTrigger input parameter and one dependency parameter.
37+
member ctx.CallActivity<'Input, 'D1, 'Output> ([<ReflectedDefinition>] azureFn: Expr<'Input * 'D1 -> Task<'Output>>, req: 'Input, ?retry: RetryOptions) : Task<'Output> =
38+
let functionName =
39+
match azureFn with
40+
| DerivedPatterns.Lambdas(_, Patterns.Call(_,mi,_)) -> mi.Name
41+
| _ -> failwith "Invalid fn"
42+
43+
match retry with
44+
| Some opt ->
45+
ctx.CallActivityWithRetryAsync<'Output>(functionName, opt, req)
46+
| None ->
47+
ctx.CallActivityAsync<'Output>(functionName, req)
48+
49+
/// Calls a function with an ActivityTrigger input parameter and two dependency parameters.
50+
member ctx.CallActivity<'Input, 'D1, 'D2, 'Output> ([<ReflectedDefinition>] azureFn: Expr<'Input * 'D1 * 'D2 -> Task<'Output>>, req: 'Input, ?retry: RetryOptions) : Task<'Output> =
51+
let functionName =
52+
match azureFn with
53+
| DerivedPatterns.Lambdas(_, Patterns.Call(_,mi,_)) -> mi.Name
54+
| _ -> failwith "Invalid fn"
55+
56+
match retry with
57+
| Some opt ->
58+
ctx.CallActivityWithRetryAsync<'Output>(functionName, opt, req)
59+
| None ->
60+
ctx.CallActivityAsync<'Output>(functionName, req)
61+
62+
/// Calls a function with an ActivityTrigger input parameter and three dependency parameters.
63+
member ctx.CallActivity<'Input, 'D1, 'D2, 'D3, 'Output> ([<ReflectedDefinition>] azureFn: Expr<'Input * 'D1 * 'D2 * 'D3 -> Task<'Output>>, req: 'Input, ?retry: RetryOptions) : Task<'Output> =
64+
let functionName =
65+
match azureFn with
66+
| DerivedPatterns.Lambdas(_, Patterns.Call(_,mi,_)) -> mi.Name
67+
| _ -> failwith "Invalid fn"
68+
69+
match retry with
70+
| Some opt ->
71+
ctx.CallActivityWithRetryAsync<'Output>(functionName, opt, req)
72+
| None ->
73+
ctx.CallActivityAsync<'Output>(functionName, req)

0 commit comments

Comments
 (0)