-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
576 additions
and
1,035 deletions.
There are no files selected for viewing
79 changes: 0 additions & 79 deletions
79
src/Microsoft.Azure.WebJobs.Host/Bindings/BindingProviders/FunctionFilterBindingProvider.cs
This file was deleted.
Oops, something went wrong.
150 changes: 82 additions & 68 deletions
150
src/Microsoft.Azure.WebJobs.Host/Executors/FunctionExecutor.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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
32 changes: 32 additions & 0 deletions
32
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionExceptionContext.cs
This file contains 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,32 @@ | ||
// 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 Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Base context class for <see cref="IFunctionExceptionFilter.OnExceptionAsync(FunctionExceptionContext, System.Threading.CancellationToken)"/>. | ||
/// </summary> | ||
public class FunctionExceptionContext : FunctionFilterContext | ||
{ | ||
/// <summary> | ||
/// Constructs a new instance | ||
/// </summary> | ||
/// <param name="functionInstanceId">The instance ID for the function invocation.</param> | ||
/// <param name="functionName">The name of the function.</param> | ||
/// <param name="logger"><see cref="ILogger"/> that can be used by the filter to log information.</param> | ||
/// <param name="exception">The function exception.</param> | ||
public FunctionExceptionContext(Guid functionInstanceId, string functionName, ILogger logger, Exception exception) | ||
: base(functionInstanceId, functionName, logger) | ||
{ | ||
Exception = exception; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="Exception"/> that caused the function invocation to fail. | ||
/// </summary> | ||
public Exception Exception { get; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionExceptionFilterAttribute.cs
This file contains 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,19 @@ | ||
// 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; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Base class for declarative function exception filters. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] | ||
public abstract class FunctionExceptionFilterAttribute : Attribute, IFunctionExceptionFilter | ||
{ | ||
/// <inheritdoc/> | ||
public abstract Task OnExceptionAsync(FunctionExceptionContext exceptionContext, CancellationToken cancellationToken); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionExecutedContext.cs
This file contains 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,36 @@ | ||
// 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.Collections.Generic; | ||
using Microsoft.Azure.WebJobs.Host.Executors; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Context class for <see cref="IFunctionInvocationFilter.OnExecutedAsync(FunctionExecutedContext, System.Threading.CancellationToken)"/>>. | ||
/// </summary> | ||
public class FunctionExecutedContext : FunctionInvocationContext | ||
{ | ||
/// <summary> | ||
/// Constructs a new instance. | ||
/// </summary> | ||
/// <param name="arguments">The function arguments.</param> | ||
/// <param name="properties">The property bag that can be used to pass information between filters.</param> | ||
/// <param name="functionInstanceId">The instance ID for the function invocation.</param> | ||
/// <param name="functionName">The name of the function.</param> | ||
/// <param name="logger"><see cref="ILogger"/> that can be used by the filter to log information.</param> | ||
/// <param name="functionResult">The function result.</param> | ||
public FunctionExecutedContext(IReadOnlyDictionary<string, object> arguments, IDictionary<string, object> properties, Guid functionInstanceId, string functionName, ILogger logger, FunctionResult functionResult) | ||
: base(arguments, properties, functionInstanceId, functionName, logger) | ||
{ | ||
FunctionResult = functionResult; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="FunctionResult"/>. | ||
/// </summary> | ||
public FunctionResult FunctionResult { get; internal set; } | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionExecutingContext.cs
This file contains 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,28 @@ | ||
// 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.Collections.Generic; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Context class for <see cref="IFunctionInvocationFilter.OnExecutingAsync(FunctionExecutingContext, System.Threading.CancellationToken)"/>>. | ||
/// </summary> | ||
public class FunctionExecutingContext : FunctionInvocationContext | ||
{ | ||
/// <summary> | ||
/// Constructs a new instance. | ||
/// </summary> | ||
/// <param name="arguments">The function arguments.</param> | ||
/// <param name="properties">The property bag that can be used to pass information between filters.</param> | ||
/// <param name="functionInstanceId">The instance ID for the function invocation.</param> | ||
/// <param name="functionName">The name of the function.</param> | ||
/// <param name="logger"><see cref="ILogger"/> that can be used by the filter to log information.</param> | ||
public FunctionExecutingContext(IReadOnlyDictionary<string, object> arguments, IDictionary<string, object> properties, Guid functionInstanceId, string functionName, ILogger logger) | ||
: base(arguments, properties, functionInstanceId, functionName, logger) | ||
{ | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionFilterContext.cs
This file contains 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,47 @@ | ||
// 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 Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Base context class for all function filter context objects. | ||
/// </summary> | ||
public abstract class FunctionFilterContext | ||
{ | ||
/// <summary> | ||
/// Constructs a new instance. | ||
/// </summary> | ||
/// <param name="functionInstanceId">The instance ID for the function invocation.</param> | ||
/// <param name="functionName">The name of the function.</param> | ||
/// <param name="logger"><see cref="ILogger"/> that can be used by the filter to log information.</param> | ||
protected FunctionFilterContext(Guid functionInstanceId, string functionName, ILogger logger) | ||
{ | ||
FunctionInstanceId = functionInstanceId; | ||
FunctionName = functionName; | ||
Logger = logger; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the function instance ID. | ||
/// </summary> | ||
public Guid FunctionInstanceId { get; } | ||
|
||
/// <summary> | ||
/// Gets the name of the function. | ||
/// </summary> | ||
public string FunctionName { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="ILogger"/> that can be used by the filter to log information. | ||
/// </summary> | ||
public ILogger Logger { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="IJobInvoker"/>. | ||
/// </summary> | ||
internal IJobInvoker Invoker { get; set; } | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Microsoft.Azure.WebJobs.Host/Filters/FunctionInvocationContext.cs
This file contains 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,40 @@ | ||
// 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.Collections.Generic; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Base context class for <see cref="IFunctionInvocationFilter"/> context objects. | ||
/// </summary> | ||
public abstract class FunctionInvocationContext : FunctionFilterContext | ||
{ | ||
/// <summary> | ||
/// Constructs a new instance. | ||
/// </summary> | ||
/// <param name="arguments">The function arguments.</param> | ||
/// <param name="properties">The property bag that can be used to pass information between filters.</param> | ||
/// <param name="functionInstanceId">The instance ID for the function invocation.</param> | ||
/// <param name="functionName">The name of the function.</param> | ||
/// <param name="logger"><see cref="ILogger"/> that can be used by the filter to log information.</param> | ||
protected FunctionInvocationContext(IReadOnlyDictionary<string, object> arguments, IDictionary<string, object> properties, Guid functionInstanceId, string functionName, ILogger logger) | ||
: base(functionInstanceId, functionName, logger) | ||
{ | ||
Arguments = arguments; | ||
Properties = properties; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the function arguments. | ||
/// </summary> | ||
public IReadOnlyDictionary<string, object> Arguments { get; } | ||
|
||
/// <summary> | ||
/// Gets the property bag that can be used to pass information between filters. | ||
/// </summary> | ||
public IDictionary<string, object> Properties { get; } | ||
} | ||
} |
This file contains 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
23 changes: 23 additions & 0 deletions
23
src/Microsoft.Azure.WebJobs.Host/Filters/IFunctionExceptionFilter.cs
This file contains 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,23 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.WebJobs.Host.Filters | ||
{ | ||
/// <summary> | ||
/// Defines a filter that will be called as part of the function invocation pipeline | ||
/// for failed function invocations. | ||
/// </summary> | ||
public interface IFunctionExceptionFilter : IFunctionFilter | ||
{ | ||
/// <summary> | ||
/// Handles the function exception. | ||
/// </summary> | ||
/// <param name="exceptionContext">The <see cref="FunctionExceptionContext"/> for the failed invocation.</param> | ||
/// <param name="cancellationToken">the cancellation token.</param> | ||
/// <returns></returns> | ||
Task OnExceptionAsync(FunctionExceptionContext exceptionContext, CancellationToken cancellationToken); | ||
} | ||
} |
Oops, something went wrong.