Skip to content

Commit 567780b

Browse files
Fixed dependency injection and review comments
1 parent f6fc193 commit 567780b

16 files changed

+52
-28
lines changed

src/WebJobs.Script/ScriptHostBuilderExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ public static IHostBuilder AddScriptHostCore(this IHostBuilder builder, ScriptAp
292292

293293
services.AddSingleton<IFileLoggingStatusManager, FileLoggingStatusManager>();
294294

295+
services.AddSingleton<IWorkerProfileManager, WorkerProfileManager>();
296+
297+
services.AddSingleton<IWorkerProfileConditionProvider, WorkerProfileConditionProvider>();
298+
295299
if (!applicationHostOptions.HasParentScope)
296300
{
297301
AddCommonServices(services);
@@ -336,7 +340,7 @@ public static void AddCommonServices(IServiceCollection services)
336340
services.AddSingleton<IWorkerProcessFactory, DefaultWorkerProcessFactory>();
337341
services.AddSingleton<IRpcWorkerProcessFactory, RpcWorkerProcessFactory>();
338342
services.AddSingleton<IWorkerProfileManager, WorkerProfileManager>();
339-
services.AddSingleton<IWorkerProfileConditionProvider, SystemConditionProvider>();
343+
services.AddSingleton<IWorkerProfileConditionProvider, WorkerProfileConditionProvider>();
340344
services.TryAddSingleton<IWebHostRpcWorkerChannelManager, WebHostRpcWorkerChannelManager>();
341345
services.TryAddSingleton<IDebugManager, DebugManager>();
342346
services.TryAddSingleton<IDebugStateProvider, DebugStateProvider>();

src/WebJobs.Script/Workers/Profiles/EnvironmentCondition.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
namespace Microsoft.Azure.WebJobs.Script.Workers
1111
{
12-
// Environment condition checks if environment variables match the expected output
12+
/// <summary>
13+
/// An implementation of an <see cref="IWorkerProfileCondition"/> that checks if
14+
/// environment variables match the expected output
15+
/// </summary>
1316
public class EnvironmentCondition : IWorkerProfileCondition
1417
{
1518
private readonly ILogger _logger;

src/WebJobs.Script/Workers/Profiles/FalseCondition.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
namespace Microsoft.Azure.WebJobs.Script.Workers
55
{
6-
// The false condition always evalues to false.
7-
// This condition is used to disable a profile when condition providers fail to resolve conditions.
6+
/// <summary>
7+
/// An implementation of an <see cref="IWorkerProfileCondition"/> that always evaluates to false.
8+
/// This condition is used to disable a profile when condition providers fail to resolve conditions.
9+
/// </summary>
810
public class FalseCondition : IWorkerProfileCondition
911
{
1012
public bool Evaluate()

src/WebJobs.Script/Workers/Profiles/HostPropertyCondition.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Microsoft.Azure.WebJobs.Script.Workers
1313
{
14-
// HostPropertycondition checks if host match the expected output for properties such as Sku, Platform, HostVersion
14+
/// <summary>
15+
/// An implementation of an <see cref="IWorkerProfileCondition"/> that checks if different host properties
16+
/// such as Sku, Platform, HostVersion match the expected output
17+
/// </summary>
1518
public class HostPropertyCondition : IWorkerProfileCondition
1619
{
1720
private readonly ILogger _logger;

src/WebJobs.Script/Workers/Profiles/IWorkerProfileCondition.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace Microsoft.Azure.WebJobs.Script.Workers
55
{
6-
// Interface for different types of conditions
6+
/// <summary>
7+
/// Interface for different types of profile conditions
8+
/// </summary>
79
public interface IWorkerProfileCondition
810
{
911
/// <summary>

src/WebJobs.Script/Workers/Profiles/IWorkerProfileConditionProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace Microsoft.Azure.WebJobs.Script.Workers.Profiles
55
{
6-
// Manage differnt conditions
6+
/// <summary>
7+
/// Interface to manage different profile condition providers
8+
/// </summary>
79
internal interface IWorkerProfileConditionProvider
810
{
911
/// <summary>

src/WebJobs.Script/Workers/Profiles/IWorkerProfileManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
namespace Microsoft.Azure.WebJobs.Script.Workers
99
{
10-
// Regulate profile operations through the profile manager
10+
/// <summary>
11+
/// Interface to regulate profile operations through the profile manager
12+
/// </summary>
1113
public interface IWorkerProfileManager
1214
{
1315
/// <summary>

src/WebJobs.Script/Workers/Profiles/WorkerDescriptionProfile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.Azure.WebJobs.Script.Workers
1010
{
11+
/// <summary>
12+
/// Class that holds data of a profile
13+
/// </summary>
1114
public class WorkerDescriptionProfile
1215
{
1316
public WorkerDescriptionProfile(string name, List<IWorkerProfileCondition> conditions, RpcWorkerDescription profileDescription)

src/WebJobs.Script/Workers/Profiles/SystemConditionProvider.cs renamed to src/WebJobs.Script/Workers/Profiles/WorkerProfileConditionProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
namespace Microsoft.Azure.WebJobs.Script.Workers
99
{
10-
internal sealed class SystemConditionProvider : IWorkerProfileConditionProvider
10+
internal sealed class WorkerProfileConditionProvider : IWorkerProfileConditionProvider
1111
{
12-
private readonly ILogger _logger;
12+
private readonly ILogger<WorkerProfileConditionProvider> _logger;
1313
private readonly IEnvironment _environment;
1414
private readonly ISystemRuntimeInformation _systemRuntimeInformation;
1515

16-
public SystemConditionProvider(ILogger logger, ISystemRuntimeInformation systemRuntimeInfo, IEnvironment environment)
16+
public WorkerProfileConditionProvider(ILogger<WorkerProfileConditionProvider> logger, ISystemRuntimeInformation systemRuntimeInfo, IEnvironment environment)
1717
{
1818
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
1919
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
20-
_systemRuntimeInformation = systemRuntimeInfo ?? throw new ArgumentNullException(nameof(systemRuntimeInfo));
20+
_systemRuntimeInformation = systemRuntimeInfo ?? SystemRuntimeInformation.Instance;
2121
}
2222

2323
/// <inheritdoc />

src/WebJobs.Script/Workers/Profiles/WorkerProfileManager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99

1010
namespace Microsoft.Azure.WebJobs.Script.Workers
1111
{
12-
// The default profile manager that manages profiles from language workers
12+
/// <summary>
13+
/// The default profile manager that manages profiles from language workers
14+
/// </summary>
1315
internal class WorkerProfileManager : IWorkerProfileManager
1416
{
1517
private readonly ILogger _logger;
1618
private readonly IEnumerable<IWorkerProfileConditionProvider> _conditionProviders;
17-
private Dictionary<string, List<WorkerDescriptionProfile>> _profiles = new Dictionary<string, List<WorkerDescriptionProfile>>();
19+
private Dictionary<string, List<WorkerDescriptionProfile>> _profiles;
1820
private string _activeProfile;
1921

20-
public WorkerProfileManager(ILogger logger, IEnumerable<IWorkerProfileConditionProvider> conditionProviders)
22+
public WorkerProfileManager(ILogger<WorkerProfileManager> logger, IEnumerable<IWorkerProfileConditionProvider> conditionProviders)
2123
{
2224
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2325
_conditionProviders = conditionProviders ?? throw new ArgumentNullException(nameof(conditionProviders));
26+
_profiles = new Dictionary<string, List<WorkerDescriptionProfile>>();
2427
_activeProfile = string.Empty;
2528
}
2629

0 commit comments

Comments
 (0)