-
Notifications
You must be signed in to change notification settings - Fork 465
Refactor code to move the current logic to search for WorkerConfigs to a default worker configuration resolver #11229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+671
−86
Merged
Changes from 13 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
5cf51b1
Refactoring to add DefaultWorkerConfigurationResolver which resolves …
surgupta-msft e644d3c
Addressing Copilot PR feedback
surgupta-msft 6dfc898
Updating release notes
surgupta-msft 1c98a16
Removed obsolete code
surgupta-msft f20fa53
DI fix in tests
surgupta-msft b0dc43f
Merge with dev
surgupta-msft ad13ac2
Implemented IOptionsFormatter for WorkerConfigurationResolverOptions
surgupta-msft a566a9f
Addressing PR feedback
surgupta-msft 76ccdc9
Build fix
surgupta-msft 0de1312
Addressing PR feedback
surgupta-msft b036344
Remove _workerConfigResolverOptions from LanguageWorkerOptionsSetup
surgupta-msft 190531d
Taking IOptionsMonitor as input in resolver
surgupta-msft a484c96
Added more tests in class WorkerConfigurationResolverOptionsSetupTests
surgupta-msft ad6a445
Rebase with main
surgupta-msft 6317c0b
Update interface IWorkerConfigurationResolver
surgupta-msft 0daca28
Addressing PR feedback
surgupta-msft c53f0fc
Adding FileSystem in TestHostBuilderExtensions
surgupta-msft 95bf08f
Fix failing test
surgupta-msft 70040bd
Adding only required configuration section in WorkerConfigurationReso…
surgupta-msft b80e363
Minor fix in test
surgupta-msft 7324929
Fixing GetDefaultWorkersDirectory_Returns_Expected test
surgupta-msft ec1929d
Updating WorkerConfigurationResolverOptionsSetup
surgupta-msft c816553
Adding WorkerConfigPaths to WorkerConfigurationResolutionInfo
surgupta-msft fe19a38
Rebase with dev
surgupta-msft 2726cc7
Addressing PR feedback
surgupta-msft 92ec61b
Addressing PR feedback
surgupta-msft 2da1eb5
Naming update
surgupta-msft 0ee0871
Naming updates
surgupta-msft bd3a331
Added Summary in IWorkerConfigurationResolver
surgupta-msft 240002d
Removed global var WorkersDirPath
surgupta-msft f7c3b22
Merge branch 'dev' into surgupta/defaultresolver
surgupta-msft 5f54ad4
Updated AddProvider() parameters
surgupta-msft 5ad5b01
Removing unused usings
surgupta-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
src/WebJobs.Script/Workers/Rpc/Configuration/DefaultWorkerConfigurationResolver.cs
This file contains hidden or 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,50 @@ | ||
// 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 System.IO; | ||
using Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc.Configuration | ||
{ | ||
// This class resolves worker configurations by scanning the "workers" directory within the Host for worker config files. | ||
internal sealed class DefaultWorkerConfigurationResolver : IWorkerConfigurationResolver | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly IOptionsMonitor<WorkerConfigurationResolverOptions> _workerConfigurationResolverOptions; | ||
|
||
public DefaultWorkerConfigurationResolver(ILoggerFactory loggerFactory, IOptionsMonitor<WorkerConfigurationResolverOptions> workerConfigurationResolverOptions) | ||
{ | ||
ArgumentNullException.ThrowIfNull(loggerFactory); | ||
_logger = loggerFactory.CreateLogger(ScriptConstants.LogCategoryWorkerConfig); | ||
surgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_workerConfigurationResolverOptions = workerConfigurationResolverOptions ?? throw new ArgumentNullException(nameof(workerConfigurationResolverOptions)); | ||
} | ||
|
||
public List<string> GetWorkerConfigPaths() | ||
surgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
surgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var workersDirPath = _workerConfigurationResolverOptions.CurrentValue.WorkersDirPath; | ||
_logger.DefaultWorkersDirectoryPath(workersDirPath); | ||
|
||
List<string> workerConfigs = new(); | ||
|
||
foreach (var workerDir in Directory.EnumerateDirectories(workersDirPath)) | ||
surgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
string workerConfigPath = Path.Combine(workerDir, RpcWorkerConstants.WorkerConfigFileName); | ||
|
||
if (File.Exists(workerConfigPath)) | ||
{ | ||
workerConfigs.Add(workerDir); | ||
} | ||
} | ||
return workerConfigs; | ||
} | ||
|
||
public IOptionsMonitor<WorkerConfigurationResolverOptions> GetWorkerConfigurationResolverOptions() | ||
{ | ||
return _workerConfigurationResolverOptions; | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.