-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy pathDurableFunctionExecutor.cs
More file actions
55 lines (46 loc) · 1.92 KB
/
Copy pathDurableFunctionExecutor.cs
File metadata and controls
55 lines (46 loc) · 1.92 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Worker.Invocation;
using Microsoft.DurableTask;
using Microsoft.DurableTask.Worker;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
namespace Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Execution;
internal partial class DurableFunctionExecutor(
IFunctionExecutor inner,
ExtendedSessionsCache extendedSessionsCache,
IDurableTaskFactory factory,
IOptions<DurableTaskWorkerOptions> options,
IHostApplicationLifetime? hostApplicationLifetime = null,
IExceptionPropertiesProvider? exceptionPropertiesProvider = null)
: IFunctionExecutor
{
private DataConverter Converter => options.Value.DataConverter;
private bool IsWorkerDraining =>
hostApplicationLifetime?.ApplicationStopping.IsCancellationRequested ?? false;
public virtual ValueTask ExecuteAsync(FunctionContext context)
{
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
if (context.TryGetOrchestrationBinding(out BindingMetadata? triggerBinding))
{
return this.RunOrchestrationAsync(context, triggerBinding);
}
if (context.TryGetEntityBinding(out triggerBinding))
{
// Entity functions are handled in middleware.
return this.RunEntityAsync(context, triggerBinding);
}
if (context.TryGetActivityBinding(out triggerBinding))
{
// Activity functions are handled in middleware.
return this.RunActivityAsync(context, triggerBinding);
}
throw new NotSupportedException(
$"Function '{context.FunctionDefinition.Name}' is not supported by {nameof(DurableFunctionExecutor)}.");
}
}