Skip to content

Commit

Permalink
feat: feature flag for peek time series messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsDue committed Dec 5, 2024
1 parent df6cdf8 commit b008cc9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/B2BApi/OutgoingMessages/PeekRequestListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
: MessageCategory.None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public enum FeatureFlagName
/// </summary>
UsePeekMessages,

/// <summary>
/// Whether to disable peek time series messages
/// </summary>
UsePeekTimeSeriesMessages,

/// <summary>
/// Whether to send requests for aggregated measured data to Wholesale, or handle it in EDI.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public interface IFeatureFlagManager
/// </summary>
Task<bool> UsePeekMessagesAsync();

/// <summary>
/// Whether to disallow actors to peek time series messages.
/// </summary>
Task<bool> UsePeekTimeSeriesMessagesAsync();

/// <summary>
/// Whether to send RequestForAggregatedMeasuredData to Wholesale or handle it in EDI.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public MicrosoftFeatureFlagManager(IFeatureManager featureManager)

public Task<bool> UsePeekMessagesAsync() => IsEnabledAsync(FeatureFlagName.UsePeekMessages);

public Task<bool> UsePeekTimeSeriesMessagesAsync() => IsEnabledAsync(FeatureFlagName.UsePeekTimeSeriesMessages);

public Task<bool> RequestStaysInEdiAsync() => IsEnabledAsync(FeatureFlagName.RequestStaysInEdi);

public Task<bool> ReceiveMeteredDataForMeasurementPointsAsync() => IsEnabledAsync(FeatureFlagName.ReceiveMeteredDataForMeasurementPoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class FeatureFlagManagerStub : IFeatureFlagManager
{
public Task<bool> UsePeekMessagesAsync() => Task.FromResult(true);

public Task<bool> UsePeekTimeSeriesMessagesAsync() => Task.FromResult(true);

public Task<bool> RequestStaysInEdiAsync() => Task.FromResult(false);

public Task<bool> ReceiveMeteredDataForMeasurementPointsAsync() => Task.FromResult(true);
Expand Down

0 comments on commit b008cc9

Please sign in to comment.