-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved handling of env reload request - handles older version of wo…
…rker sdk (#1955) * Handling specialization not supported case. * Handling older worker version for environment reload request. * Fix application path. * package version bump * PR feedback: Switched to async overload for deserialization. Updated global.json to use rc2 * PR feedback - type renames as suggested.
- Loading branch information
Showing
10 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
host/src/FunctionsNetHost/Grpc/Exceptions/EnvironmentReloadNotSupportedException.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,15 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Azure.Functions.Worker | ||
{ | ||
/// <summary> | ||
/// The exception that is thrown when the current function app payload does not support environment reload. | ||
/// </summary> | ||
public sealed class EnvironmentReloadNotSupportedException : NotSupportedException | ||
{ | ||
public EnvironmentReloadNotSupportedException() { } | ||
|
||
public EnvironmentReloadNotSupportedException(string message) : base(message) { } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
host/src/FunctionsNetHost/Grpc/Exceptions/FunctionAppPayloadNotFoundException.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,15 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Azure.Functions.Worker | ||
{ | ||
/// <summary> | ||
/// The exception that is thrown when there is no function app payload found. | ||
/// </summary> | ||
public sealed class FunctionAppPayloadNotFoundException : Exception | ||
{ | ||
public FunctionAppPayloadNotFoundException() { } | ||
|
||
public FunctionAppPayloadNotFoundException(string message) : base(message) { } | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfig.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,13 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace FunctionsNetHost.Grpc | ||
{ | ||
/// <summary> | ||
/// Represents a worker configuration instance. | ||
/// </summary> | ||
public sealed class WorkerConfig | ||
{ | ||
public WorkerDescription? Description { set; get; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfigSerializerContext.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,11 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace FunctionsNetHost.Grpc | ||
{ | ||
[JsonSerializable(typeof(WorkerConfig))] | ||
[JsonSourceGenerationOptions(IncludeFields = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] | ||
internal partial class WorkerConfigSerializerContext : JsonSerializerContext { } | ||
} |
39 changes: 39 additions & 0 deletions
39
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfigUtils.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,39 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Text.Json; | ||
|
||
namespace FunctionsNetHost.Grpc | ||
{ | ||
internal static class WorkerConfigUtils | ||
{ | ||
/// <summary> | ||
/// Builds and returns an instance of <see cref="WorkerConfig"/> from the worker.config.json file if present in the application directory. | ||
/// </summary> | ||
/// <param name="applicationDirectory">The directory where function app deployed payload is present.</param> | ||
internal static async Task<WorkerConfig?> GetWorkerConfig(string applicationDirectory) | ||
{ | ||
string workerConfigPath = string.Empty; | ||
|
||
try | ||
{ | ||
workerConfigPath = Path.Combine(applicationDirectory, "worker.config.json"); | ||
|
||
using Stream stream = File.OpenRead(workerConfigPath); | ||
var workerConfig = await JsonSerializer.DeserializeAsync(stream, WorkerConfigSerializerContext.Default.WorkerConfig); | ||
|
||
return workerConfig; | ||
} | ||
catch (FileNotFoundException) | ||
{ | ||
Logger.Log($"worker.config.json not found at {workerConfigPath}. This may indicate missing app payload."); | ||
return null; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Log($"Error in WorkerConfigUtils.GetWorkerConfig.{ex}"); | ||
return null; | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerDescription.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,12 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace FunctionsNetHost.Grpc | ||
{ | ||
public sealed class WorkerDescription | ||
{ | ||
public string? DefaultWorkerPath { set; get; } | ||
|
||
public bool CanUsePlaceholder { set; 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
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