-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBusinessHoursPolicy.cs
More file actions
30 lines (26 loc) · 1.06 KB
/
Copy pathBusinessHoursPolicy.cs
File metadata and controls
30 lines (26 loc) · 1.06 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
using FeatureFlags.State;
using ModularityKit.Mutator.Abstractions.Engine;
using ModularityKit.Mutator.Abstractions.Intent;
using ModularityKit.Mutator.Abstractions.Policies;
namespace FeatureFlags.Policies;
/// <summary>
/// Policy that restricts high risk mutations to business hours (9:00-17:00 UTC).
/// </summary>
public class BusinessHoursPolicy : IMutationPolicy<FeatureFlagsState>
{
public string Name => "BusinessHoursPolicy";
public int Priority => 100;
public string Description => "High-risk mutations are only allowed during business hours (9:00-17:00 UTC).";
public PolicyDecision Evaluate(IMutation<FeatureFlagsState> mutation, FeatureFlagsState state)
{
if (mutation.Intent.RiskLevel < MutationRiskLevel.High) return PolicyDecision.Allow(Name);
var hour = DateTime.UtcNow.Hour;
if (hour is < 9 or >= 17)
{
return PolicyDecision.Deny(
"High-risk changes are only allowed during business hours (9-17 UTC).",
Name);
}
return PolicyDecision.Allow(Name);
}
}