using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
namespace ZB.MOM.WW.ScadaBridge.DeploymentManager;
/// Recomputes deployment revisions from authoritative configuration on every probe.
/// Process-local watermarks cannot prove freshness after another central changes the shared store,
/// so nothing is memoised across calls.
public sealed class StaleInstanceProbe : IStaleInstanceProbe
{
private readonly IFlatteningPipeline _flatteningPipeline;
/// Initializes the authoritative probe.
/// The pipeline used to flatten instances for staleness comparison.
public StaleInstanceProbe(IFlatteningPipeline flatteningPipeline)
{
_flatteningPipeline = flatteningPipeline ?? throw new ArgumentNullException(nameof(flatteningPipeline));
}
///
public async Task GetCurrentRevisionHashAsync(int instanceId, CancellationToken cancellationToken = default)
{
// Hash only: staleness never reads the validation result.
var result = await _flatteningPipeline.ComputeRevisionHashAsync(
instanceId, _flatteningPipeline.CreateSession(), cancellationToken).ConfigureAwait(false);
return result.IsSuccess ? result.Value : null;
}
}