From b008cc9da615781772d0925a572fc6a257e833a2 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Thu, 5 Dec 2024 14:30:26 +0100 Subject: [PATCH] feat: feature flag for peek time series messages --- source/B2BApi/OutgoingMessages/PeekRequestListener.cs | 8 ++++++++ .../FeatureFlag/FeatureFlagName.cs | 5 +++++ .../FeatureFlag/IFeatureFlagManager.cs | 5 +++++ .../FeatureFlag/MicrosoftFeatureFlagManager.cs | 2 ++ .../TestDoubles/FeatureFlagManagerStub.cs | 2 ++ 5 files changed, 22 insertions(+) diff --git a/source/B2BApi/OutgoingMessages/PeekRequestListener.cs b/source/B2BApi/OutgoingMessages/PeekRequestListener.cs index abf716af7..c08f5605b 100644 --- a/source/B2BApi/OutgoingMessages/PeekRequestListener.cs +++ b/source/B2BApi/OutgoingMessages/PeekRequestListener.cs @@ -97,6 +97,14 @@ await _auditLogger.LogWithCommitAsync( return noContentResponse; } + if (!await _featureFlagManager.UsePeekTimeSeriesMessagesAsync().ConfigureAwait(false)) + { + var noContentResponse = HttpResponseData.CreateResponse(request); + noContentResponse.Headers.Add("Content-Type", $"{desiredDocumentFormat.GetContentType()}; charset=utf-8"); + noContentResponse.StatusCode = HttpStatusCode.NoContent; + return noContentResponse; + } + var parsedMessageCategory = messageCategory != null && desiredDocumentFormat != DocumentFormat.Ebix ? EnumerationType.FromName(messageCategory) : MessageCategory.None; diff --git a/source/BuildingBlocks.Infrastructure/FeatureFlag/FeatureFlagName.cs b/source/BuildingBlocks.Infrastructure/FeatureFlag/FeatureFlagName.cs index b0e19d080..cbe12f866 100644 --- a/source/BuildingBlocks.Infrastructure/FeatureFlag/FeatureFlagName.cs +++ b/source/BuildingBlocks.Infrastructure/FeatureFlag/FeatureFlagName.cs @@ -25,6 +25,11 @@ public enum FeatureFlagName /// UsePeekMessages, + /// + /// Whether to disable peek time series messages + /// + UsePeekTimeSeriesMessages, + /// /// Whether to send requests for aggregated measured data to Wholesale, or handle it in EDI. /// diff --git a/source/BuildingBlocks.Infrastructure/FeatureFlag/IFeatureFlagManager.cs b/source/BuildingBlocks.Infrastructure/FeatureFlag/IFeatureFlagManager.cs index c519b1f62..fe091233f 100644 --- a/source/BuildingBlocks.Infrastructure/FeatureFlag/IFeatureFlagManager.cs +++ b/source/BuildingBlocks.Infrastructure/FeatureFlag/IFeatureFlagManager.cs @@ -29,6 +29,11 @@ public interface IFeatureFlagManager /// Task UsePeekMessagesAsync(); + /// + /// Whether to disallow actors to peek time series messages. + /// + Task UsePeekTimeSeriesMessagesAsync(); + /// /// Whether to send RequestForAggregatedMeasuredData to Wholesale or handle it in EDI. /// diff --git a/source/BuildingBlocks.Infrastructure/FeatureFlag/MicrosoftFeatureFlagManager.cs b/source/BuildingBlocks.Infrastructure/FeatureFlag/MicrosoftFeatureFlagManager.cs index d8bb78756..422c6d0c4 100644 --- a/source/BuildingBlocks.Infrastructure/FeatureFlag/MicrosoftFeatureFlagManager.cs +++ b/source/BuildingBlocks.Infrastructure/FeatureFlag/MicrosoftFeatureFlagManager.cs @@ -30,6 +30,8 @@ public MicrosoftFeatureFlagManager(IFeatureManager featureManager) public Task UsePeekMessagesAsync() => IsEnabledAsync(FeatureFlagName.UsePeekMessages); + public Task UsePeekTimeSeriesMessagesAsync() => IsEnabledAsync(FeatureFlagName.UsePeekTimeSeriesMessages); + public Task RequestStaysInEdiAsync() => IsEnabledAsync(FeatureFlagName.RequestStaysInEdi); public Task ReceiveMeteredDataForMeasurementPointsAsync() => IsEnabledAsync(FeatureFlagName.ReceiveMeteredDataForMeasurementPoints); diff --git a/source/BuildingBlocks.Tests/TestDoubles/FeatureFlagManagerStub.cs b/source/BuildingBlocks.Tests/TestDoubles/FeatureFlagManagerStub.cs index 3679ed89c..054473844 100644 --- a/source/BuildingBlocks.Tests/TestDoubles/FeatureFlagManagerStub.cs +++ b/source/BuildingBlocks.Tests/TestDoubles/FeatureFlagManagerStub.cs @@ -25,6 +25,8 @@ public class FeatureFlagManagerStub : IFeatureFlagManager { public Task UsePeekMessagesAsync() => Task.FromResult(true); + public Task UsePeekTimeSeriesMessagesAsync() => Task.FromResult(true); + public Task RequestStaysInEdiAsync() => Task.FromResult(false); public Task ReceiveMeteredDataForMeasurementPointsAsync() => Task.FromResult(true);