release orchestrator v1 draft and build fixes
This commit is contained in:
@@ -19,15 +19,18 @@ public sealed class FidelitySloAlertingService
|
||||
private readonly FidelityMetricsTelemetry _telemetry;
|
||||
private readonly FidelitySloOptions _options;
|
||||
private readonly ILogger<FidelitySloAlertingService> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public FidelitySloAlertingService(
|
||||
FidelityMetricsTelemetry telemetry,
|
||||
IOptions<FidelitySloOptions> options,
|
||||
ILogger<FidelitySloAlertingService> logger)
|
||||
ILogger<FidelitySloAlertingService> logger,
|
||||
TimeProvider? timeProvider = null)
|
||||
{
|
||||
_telemetry = telemetry ?? throw new ArgumentNullException(nameof(telemetry));
|
||||
_options = options?.Value ?? new FidelitySloOptions();
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_timeProvider = timeProvider ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -128,7 +131,7 @@ public sealed class FidelitySloAlertingService
|
||||
{
|
||||
Passed = breaches.Count == 0,
|
||||
Breaches = breaches,
|
||||
EvaluatedAt = DateTimeOffset.UtcNow
|
||||
EvaluatedAt = _timeProvider.GetUtcNow()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -123,14 +123,26 @@ public sealed record IncidentModeState
|
||||
public required string ActivationId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this state has expired.
|
||||
/// Gets whether this state has expired (using system time).
|
||||
/// For deterministic checks, use <see cref="IsExpiredAt"/>.
|
||||
/// </summary>
|
||||
public bool IsExpired => DateTimeOffset.UtcNow >= ExpiresAt;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining time until expiration.
|
||||
/// Checks whether this state has expired at a specific point in time.
|
||||
/// </summary>
|
||||
public bool IsExpiredAt(DateTimeOffset asOf) => asOf >= ExpiresAt;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining time until expiration (using system time).
|
||||
/// For deterministic checks, use <see cref="RemainingTimeAt"/>.
|
||||
/// </summary>
|
||||
public TimeSpan RemainingTime => IsExpired ? TimeSpan.Zero : ExpiresAt - DateTimeOffset.UtcNow;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the remaining time until expiration at a specific point in time.
|
||||
/// </summary>
|
||||
public TimeSpan RemainingTimeAt(DateTimeOffset asOf) => IsExpiredAt(asOf) ? TimeSpan.Zero : ExpiresAt - asOf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user