alerting(core): drop unused perExchangeLingerSeconds from ExchangeMatchCondition
Dead field — was enforced by compact ctor as required for PER_EXCHANGE, but never read anywhere in the codebase. Removal tightens the API surface and is precondition for the Task 3.3 cross-field validator. Pre-prod; no shim / migration.
This commit is contained in:
@@ -9,8 +9,7 @@ public record ExchangeMatchCondition(
|
||||
ExchangeFilter filter,
|
||||
FireMode fireMode,
|
||||
Integer threshold, // required when COUNT_IN_WINDOW; null for PER_EXCHANGE
|
||||
Integer windowSeconds, // required when COUNT_IN_WINDOW
|
||||
Integer perExchangeLingerSeconds // required when PER_EXCHANGE
|
||||
Integer windowSeconds // required when COUNT_IN_WINDOW
|
||||
) implements AlertCondition {
|
||||
|
||||
public ExchangeMatchCondition {
|
||||
@@ -18,8 +17,6 @@ public record ExchangeMatchCondition(
|
||||
throw new IllegalArgumentException("fireMode is required (PER_EXCHANGE or COUNT_IN_WINDOW)");
|
||||
if (fireMode == FireMode.COUNT_IN_WINDOW && (threshold == null || windowSeconds == null))
|
||||
throw new IllegalArgumentException("COUNT_IN_WINDOW requires threshold + windowSeconds");
|
||||
if (fireMode == FireMode.PER_EXCHANGE && perExchangeLingerSeconds == null)
|
||||
throw new IllegalArgumentException("PER_EXCHANGE requires perExchangeLingerSeconds");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ class AlertConditionJsonTest {
|
||||
var c = new ExchangeMatchCondition(
|
||||
new AlertScope("orders", null, null),
|
||||
new ExchangeMatchCondition.ExchangeFilter("FAILED", Map.of("type","payment")),
|
||||
FireMode.PER_EXCHANGE, null, null, 300);
|
||||
FireMode.PER_EXCHANGE, null, null);
|
||||
String json = om.writeValueAsString((AlertCondition) c);
|
||||
AlertCondition parsed = om.readValue(json, AlertCondition.class);
|
||||
assertThat(parsed).isInstanceOf(ExchangeMatchCondition.class);
|
||||
@@ -39,7 +39,7 @@ class AlertConditionJsonTest {
|
||||
var c = new ExchangeMatchCondition(
|
||||
new AlertScope("orders", null, null),
|
||||
new ExchangeMatchCondition.ExchangeFilter("FAILED", Map.of()),
|
||||
FireMode.COUNT_IN_WINDOW, 5, 900, null);
|
||||
FireMode.COUNT_IN_WINDOW, 5, 900);
|
||||
AlertCondition parsed = om.readValue(om.writeValueAsString((AlertCondition) c), AlertCondition.class);
|
||||
assertThat(((ExchangeMatchCondition) parsed).threshold()).isEqualTo(5);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class AlertConditionJsonTest {
|
||||
assertThatThrownBy(() -> new ExchangeMatchCondition(
|
||||
new AlertScope(null, null, null),
|
||||
new ExchangeMatchCondition.ExchangeFilter("FAILED", Map.of()),
|
||||
null, null, null, null))
|
||||
null, null, null))
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessageContaining("fireMode");
|
||||
}
|
||||
@@ -63,8 +63,7 @@ class AlertConditionJsonTest {
|
||||
"filter": {"status": "FAILED", "attributes": {}},
|
||||
"fireMode": null,
|
||||
"threshold": null,
|
||||
"windowSeconds": null,
|
||||
"perExchangeLingerSeconds": null
|
||||
"windowSeconds": null
|
||||
}
|
||||
""";
|
||||
assertThatThrownBy(() -> om.readValue(json, AlertCondition.class))
|
||||
|
||||
Reference in New Issue
Block a user