Skip to content

Commit a8213ca

Browse files
fix: Handle default value for retry period on reorder policies correctly
1 parent 099fbc2 commit a8213ca

File tree

7 files changed

+27
-30
lines changed

7 files changed

+27
-30
lines changed

.claude/reference/architecture.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ ChunkTimeInterval = "7 days" // ChunkTimeIntervalLong = 604_800_000_000L
129129
ReorderPolicyScheduleInterval = "1 day"
130130
ReorderPolicyMaxRetries = -1 // indefinite
131131
ReorderPolicyMaxRuntime = "00:00:00" // no limit
132-
ReorderPolicyRetryPeriod = "00:05:00"
133132
```
134133

135134
## Design Library Structure

src/Eftdb.Design/Scaffolding/ReorderPolicyAnnotationApplier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void ApplyAnnotations(DatabaseTable table, object featureInfo)
4040
table[ReorderPolicyAnnotations.MaxRetries] = policyInfo.MaxRetries;
4141
}
4242

43-
if (policyInfo.RetryPeriod != DefaultValues.ReorderPolicyRetryPeriod)
43+
if (policyInfo.RetryPeriod != DefaultValues.ReorderPolicyScheduleInterval)
4444
{
4545
table[ReorderPolicyAnnotations.RetryPeriod] = policyInfo.RetryPeriod;
4646
}

src/Eftdb/DefaultValues.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ public static class DefaultValues
1111
public const string ReorderPolicyScheduleInterval = "1 day";
1212
public const int ReorderPolicyMaxRetries = -1;
1313
public const string ReorderPolicyMaxRuntime = "00:00:00";
14-
public const string ReorderPolicyRetryPeriod = "00:05:00";
1514
}
1615
}

src/Eftdb/Generators/ReorderPolicyOperationGenerator.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,17 @@ public List<string> Generate(DropReorderPolicyOperation operation)
9090
private static List<string> BuildAlterJobClauses(AddReorderPolicyOperation operation)
9191
{
9292
List<string> clauses = [];
93-
// Assuming DefaultValues is accessible or static constants
94-
// Note: You may need to adjust the default value comparisons if DefaultValues isn't available
95-
if (!string.IsNullOrWhiteSpace(operation.ScheduleInterval)) // && operation.ScheduleInterval != DefaultValues.ReorderPolicyScheduleInterval)
93+
94+
if (!string.IsNullOrWhiteSpace(operation.ScheduleInterval))
9695
clauses.Add($"schedule_interval => INTERVAL '{operation.ScheduleInterval}'");
9796

98-
if (!string.IsNullOrWhiteSpace(operation.MaxRuntime)) // && operation.MaxRuntime != DefaultValues.ReorderPolicyMaxRuntime)
97+
if (!string.IsNullOrWhiteSpace(operation.MaxRuntime))
9998
clauses.Add($"max_runtime => INTERVAL '{operation.MaxRuntime}'");
10099

101-
if (operation.MaxRetries != null) // && operation.MaxRetries != DefaultValues.ReorderPolicyMaxRetries)
100+
if (operation.MaxRetries != null)
102101
clauses.Add($"max_retries => {operation.MaxRetries}");
103102

104-
if (!string.IsNullOrWhiteSpace(operation.RetryPeriod)) // && operation.RetryPeriod != DefaultValues.ReorderPolicyRetryPeriod)
103+
if (!string.IsNullOrWhiteSpace(operation.RetryPeriod))
105104
clauses.Add($"retry_period => INTERVAL '{operation.RetryPeriod}'");
106105

107106
return clauses;

src/Eftdb/Internals/Features/ReorderPolicies/ReorderPolicyModelExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static IEnumerable<AddReorderPolicyOperation> GetReorderPolicies(IRelatio
4040
ScheduleInterval = entityType.FindAnnotation(ReorderPolicyAnnotations.ScheduleInterval)?.Value as string ?? DefaultValues.ReorderPolicyScheduleInterval,
4141
MaxRuntime = entityType.FindAnnotation(ReorderPolicyAnnotations.MaxRuntime)?.Value as string ?? DefaultValues.ReorderPolicyMaxRuntime,
4242
MaxRetries = entityType.FindAnnotation(ReorderPolicyAnnotations.MaxRetries)?.Value as int? ?? DefaultValues.ReorderPolicyMaxRetries,
43-
RetryPeriod = entityType.FindAnnotation(ReorderPolicyAnnotations.RetryPeriod)?.Value as string ?? DefaultValues.ReorderPolicyRetryPeriod
43+
RetryPeriod = entityType.FindAnnotation(ReorderPolicyAnnotations.RetryPeriod)?.Value as string ?? DefaultValues.ReorderPolicyScheduleInterval
4444
};
4545
}
4646
}

tests/Eftdb.Tests/Extractors/ReorderPolicyModelExtractorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void Should_Extract_Minimal_ReorderPolicy()
6565
Assert.Equal(DefaultValues.ReorderPolicyScheduleInterval, operation.ScheduleInterval);
6666
Assert.Equal(DefaultValues.ReorderPolicyMaxRuntime, operation.MaxRuntime);
6767
Assert.Equal(DefaultValues.ReorderPolicyMaxRetries, operation.MaxRetries);
68-
Assert.Equal(DefaultValues.ReorderPolicyRetryPeriod, operation.RetryPeriod);
68+
Assert.Equal(DefaultValues.ReorderPolicyScheduleInterval, operation.RetryPeriod);
6969
}
7070

7171
#endregion
@@ -555,7 +555,7 @@ public void Should_Use_Default_RetryPeriod_When_Not_Specified()
555555
List<AddReorderPolicyOperation> operations = [.. ReorderPolicyModelExtractor.GetReorderPolicies(relationalModel)];
556556

557557
Assert.Single(operations);
558-
Assert.Equal(DefaultValues.ReorderPolicyRetryPeriod, operations[0].RetryPeriod);
558+
Assert.Equal(DefaultValues.ReorderPolicyScheduleInterval, operations[0].RetryPeriod);
559559
}
560560

561561
#endregion

tests/Eftdb.Tests/Scaffolding/ReorderPolicyAnnotationApplierTests.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Should_Apply_Minimal_ReorderPolicy_Annotations()
2727
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
2828
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
2929
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
30-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
30+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
3131
);
3232

3333
// Act
@@ -60,7 +60,7 @@ public void Should_Apply_HasReorderPolicy_Always_True()
6060
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
6161
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
6262
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
63-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
63+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
6464
);
6565

6666
// Act
@@ -88,7 +88,7 @@ public void Should_Apply_IndexName_Annotation()
8888
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
8989
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
9090
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
91-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
91+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
9292
);
9393

9494
// Act
@@ -114,7 +114,7 @@ public void Should_Apply_InitialStart_Annotation()
114114
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
115115
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
116116
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
117-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
117+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
118118
);
119119

120120
// Act
@@ -139,7 +139,7 @@ public void Should_Not_Apply_InitialStart_When_Null()
139139
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
140140
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
141141
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
142-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
142+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
143143
);
144144

145145
// Act
@@ -164,7 +164,7 @@ public void Should_Apply_ScheduleInterval_When_Different_From_Default()
164164
ScheduleInterval: "7 days",
165165
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
166166
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
167-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
167+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
168168
);
169169

170170
// Act
@@ -189,7 +189,7 @@ public void Should_Not_Apply_ScheduleInterval_When_Default()
189189
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval, // "1 day"
190190
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
191191
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
192-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
192+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
193193
);
194194

195195
// Act
@@ -219,7 +219,7 @@ public void Should_Apply_Various_ScheduleInterval_Formats(string scheduleInterva
219219
ScheduleInterval: scheduleInterval,
220220
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
221221
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
222-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
222+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
223223
);
224224

225225
// Act
@@ -244,7 +244,7 @@ public void Should_Apply_MaxRuntime_When_Different_From_Default()
244244
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
245245
MaxRuntime: "01:00:00",
246246
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
247-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
247+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
248248
);
249249

250250
// Act
@@ -269,7 +269,7 @@ public void Should_Not_Apply_MaxRuntime_When_Default()
269269
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
270270
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime, // "00:00:00"
271271
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
272-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
272+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
273273
);
274274

275275
// Act
@@ -294,7 +294,7 @@ public void Should_Apply_MaxRetries_When_Different_From_Default()
294294
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
295295
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
296296
MaxRetries: 5,
297-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
297+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
298298
);
299299

300300
// Act
@@ -319,7 +319,7 @@ public void Should_Not_Apply_MaxRetries_When_Default()
319319
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
320320
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
321321
MaxRetries: DefaultValues.ReorderPolicyMaxRetries, // -1
322-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
322+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
323323
);
324324

325325
// Act
@@ -344,7 +344,7 @@ public void Should_Apply_MaxRetries_Zero()
344344
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
345345
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
346346
MaxRetries: 0,
347-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
347+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
348348
);
349349

350350
// Act
@@ -373,7 +373,7 @@ public void Should_Apply_MaxRetries_Positive_Values(int maxRetries)
373373
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
374374
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
375375
MaxRetries: maxRetries,
376-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
376+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
377377
);
378378

379379
// Act
@@ -423,7 +423,7 @@ public void Should_Not_Apply_RetryPeriod_When_Default()
423423
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
424424
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
425425
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
426-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod // "00:05:00"
426+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval // "00:05:00"
427427
);
428428

429429
// Act
@@ -598,7 +598,7 @@ public void Should_Preserve_Existing_Table_Properties()
598598
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
599599
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
600600
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
601-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
601+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
602602
);
603603

604604
// Act
@@ -629,7 +629,7 @@ public void Should_Handle_IndexName_With_Schema_Prefix()
629629
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
630630
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
631631
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
632-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
632+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
633633
);
634634

635635
// Act
@@ -655,7 +655,7 @@ public void Should_Handle_Various_InitialStart_DateTimes(DateTime initialStart)
655655
ScheduleInterval: DefaultValues.ReorderPolicyScheduleInterval,
656656
MaxRuntime: DefaultValues.ReorderPolicyMaxRuntime,
657657
MaxRetries: DefaultValues.ReorderPolicyMaxRetries,
658-
RetryPeriod: DefaultValues.ReorderPolicyRetryPeriod
658+
RetryPeriod: DefaultValues.ReorderPolicyScheduleInterval
659659
);
660660

661661
// Act

0 commit comments

Comments
 (0)