Skip to content

Commit abd30cb

Browse files
committed
rename maxRetries to maxAttempts
1 parent 707cdf6 commit abd30cb

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

apps/webapp/app/v3/runEngine.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function createRunEngine() {
7878
duration: env.RUN_ENGINE_RUN_LOCK_DURATION,
7979
automaticExtensionThreshold: env.RUN_ENGINE_RUN_LOCK_AUTOMATIC_EXTENSION_THRESHOLD,
8080
retryConfig: {
81-
maxRetries: env.RUN_ENGINE_RUN_LOCK_MAX_RETRIES,
81+
maxAttempts: env.RUN_ENGINE_RUN_LOCK_MAX_RETRIES,
8282
baseDelay: env.RUN_ENGINE_RUN_LOCK_BASE_DELAY,
8383
maxDelay: env.RUN_ENGINE_RUN_LOCK_MAX_DELAY,
8484
backoffMultiplier: env.RUN_ENGINE_RUN_LOCK_BACKOFF_MULTIPLIER,

internal-packages/run-engine/src/engine/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class RunEngine {
101101
duration: options.runLock.duration ?? 5000,
102102
automaticExtensionThreshold: options.runLock.automaticExtensionThreshold ?? 1000,
103103
retryConfig: {
104-
maxRetries: 10,
104+
maxAttempts: 10,
105105
baseDelay: 100,
106106
maxDelay: 3000,
107107
backoffMultiplier: 1.8,

internal-packages/run-engine/src/engine/locking.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ interface ManualLockContext {
5252
}
5353

5454
export interface LockRetryConfig {
55-
/** Maximum number of retry attempts (default: 10) */
56-
maxRetries?: number;
55+
/** Maximum number of locking attempts (default: 10) */
56+
maxAttempts?: number;
5757
/** Initial delay in milliseconds (default: 200) */
5858
baseDelay?: number;
5959
/** Maximum delay cap in milliseconds (default: 5000) */
@@ -102,7 +102,7 @@ export class RunLocker {
102102

103103
// Initialize retry configuration with defaults
104104
this.retryConfig = {
105-
maxRetries: options.retryConfig?.maxRetries ?? 10,
105+
maxAttempts: options.retryConfig?.maxAttempts ?? 10,
106106
baseDelay: options.retryConfig?.baseDelay ?? 200,
107107
maxDelay: options.retryConfig?.maxDelay ?? 5000,
108108
backoffMultiplier: options.retryConfig?.backoffMultiplier ?? 1.5,
@@ -206,7 +206,7 @@ export class RunLocker {
206206
const joinedResources = sortedResources.join(",");
207207

208208
// Use configured retry settings with exponential backoff
209-
const { maxRetries, baseDelay, maxDelay, backoffMultiplier, jitterFactor, maxTotalWaitTime } =
209+
const { maxAttempts, baseDelay, maxDelay, backoffMultiplier, jitterFactor, maxTotalWaitTime } =
210210
this.retryConfig;
211211

212212
// Track timing for total wait time limit
@@ -216,7 +216,7 @@ export class RunLocker {
216216
let lock: redlock.Lock | undefined;
217217
let lastError: Error | undefined;
218218

219-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
219+
for (let attempt = 0; attempt <= maxAttempts; attempt++) {
220220
const [error, acquiredLock] = await tryCatch(this.redlock.acquire(sortedResources, duration));
221221

222222
if (!error && acquiredLock) {
@@ -254,7 +254,7 @@ export class RunLocker {
254254
}
255255

256256
// If this is the last attempt, throw timeout error
257-
if (attempt === maxRetries) {
257+
if (attempt === maxAttempts) {
258258
this.logger.warn("[RunLocker] Lock acquisition exhausted all retries", {
259259
name,
260260
resources: sortedResources,
@@ -320,14 +320,14 @@ export class RunLocker {
320320
this.logger.error("[RunLocker] Lock was not acquired despite completing retry loop", {
321321
name,
322322
resources: sortedResources,
323-
maxRetries,
323+
maxAttempts,
324324
totalWaitTime: Math.round(totalWaitTime),
325325
lastError: lastError?.message,
326326
});
327327
throw new LockAcquisitionTimeoutError(
328328
sortedResources,
329329
Math.round(totalWaitTime),
330-
maxRetries + 1,
330+
maxAttempts + 1,
331331
`Lock acquisition on resources [${sortedResources.join(", ")}] failed unexpectedly`
332332
);
333333
}

internal-packages/run-engine/src/engine/tests/locking.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe("RunLocker", () => {
115115
logger,
116116
tracer: trace.getTracer("RunLockTest"),
117117
retryConfig: {
118-
maxRetries: 3,
118+
maxAttempts: 3,
119119
baseDelay: 100,
120120
maxTotalWaitTime: 2000, // 2 second timeout for faster test
121121
},
@@ -246,7 +246,7 @@ describe("RunLocker", () => {
246246
logger,
247247
tracer: trace.getTracer("RunLockTest"),
248248
retryConfig: {
249-
maxRetries: 2,
249+
maxAttempts: 2,
250250
baseDelay: 50,
251251
maxDelay: 200,
252252
backoffMultiplier: 2.0,
@@ -258,7 +258,7 @@ describe("RunLocker", () => {
258258
try {
259259
// Verify configuration is set correctly
260260
const config = runLock.getRetryConfig();
261-
expect(config.maxRetries).toBe(2);
261+
expect(config.maxAttempts).toBe(2);
262262
expect(config.baseDelay).toBe(50);
263263
expect(config.maxDelay).toBe(200);
264264
expect(config.backoffMultiplier).toBe(2.0);
@@ -288,7 +288,7 @@ describe("RunLocker", () => {
288288
logger,
289289
tracer: trace.getTracer("RunLockTest"),
290290
retryConfig: {
291-
maxRetries: 2,
291+
maxAttempts: 2,
292292
baseDelay: 50,
293293
maxTotalWaitTime: 500, // Shorter timeout to ensure failure
294294
},
@@ -315,7 +315,7 @@ describe("RunLocker", () => {
315315
if (error instanceof LockAcquisitionTimeoutError) {
316316
expect(error.resources).toEqual(["test-error"]);
317317
expect(error.attempts).toBeGreaterThan(0);
318-
expect(error.attempts).toBeLessThanOrEqual(3); // maxRetries + 1
318+
expect(error.attempts).toBeLessThanOrEqual(3); // maxAttempts + 1
319319
expect(error.totalWaitTime).toBeGreaterThan(0);
320320
expect(error.totalWaitTime).toBeLessThanOrEqual(800); // Some tolerance
321321
expect(error.name).toBe("LockAcquisitionTimeoutError");
@@ -344,7 +344,7 @@ describe("RunLocker", () => {
344344

345345
try {
346346
const config = runLock.getRetryConfig();
347-
expect(config.maxRetries).toBe(10);
347+
expect(config.maxAttempts).toBe(10);
348348
expect(config.baseDelay).toBe(200);
349349
expect(config.maxDelay).toBe(5000);
350350
expect(config.backoffMultiplier).toBe(1.5);
@@ -371,15 +371,15 @@ describe("RunLocker", () => {
371371
logger,
372372
tracer: trace.getTracer("RunLockTest"),
373373
retryConfig: {
374-
maxRetries: 5,
374+
maxAttempts: 5,
375375
maxTotalWaitTime: 10000,
376376
// Other values should use defaults
377377
},
378378
});
379379

380380
try {
381381
const config = runLock.getRetryConfig();
382-
expect(config.maxRetries).toBe(5); // Overridden
382+
expect(config.maxAttempts).toBe(5); // Overridden
383383
expect(config.maxTotalWaitTime).toBe(10000); // Overridden
384384
expect(config.baseDelay).toBe(200); // Default
385385
expect(config.maxDelay).toBe(5000); // Default
@@ -643,7 +643,7 @@ describe("RunLocker", () => {
643643
duration: 3000,
644644
automaticExtensionThreshold: 300,
645645
retryConfig: {
646-
maxRetries: 5,
646+
maxAttempts: 5,
647647
baseDelay: 150,
648648
},
649649
});
@@ -654,7 +654,7 @@ describe("RunLocker", () => {
654654
expect(runLock.getAutomaticExtensionThreshold()).toBe(300);
655655

656656
const retryConfig = runLock.getRetryConfig();
657-
expect(retryConfig.maxRetries).toBe(5);
657+
expect(retryConfig.maxAttempts).toBe(5);
658658
expect(retryConfig.baseDelay).toBe(150);
659659

660660
// Test basic functionality with all custom configs
@@ -681,7 +681,7 @@ describe("RunLocker", () => {
681681
duration: 10000,
682682
automaticExtensionThreshold: 2000,
683683
retryConfig: {
684-
maxRetries: 15,
684+
maxAttempts: 15,
685685
baseDelay: 100,
686686
maxDelay: 3000,
687687
backoffMultiplier: 1.8,
@@ -696,7 +696,7 @@ describe("RunLocker", () => {
696696
expect(runLock.getAutomaticExtensionThreshold()).toBe(2000);
697697

698698
const retryConfig = runLock.getRetryConfig();
699-
expect(retryConfig.maxRetries).toBe(15);
699+
expect(retryConfig.maxAttempts).toBe(15);
700700
expect(retryConfig.baseDelay).toBe(100);
701701
expect(retryConfig.maxDelay).toBe(3000);
702702
expect(retryConfig.backoffMultiplier).toBe(1.8);
@@ -722,22 +722,22 @@ describe("RunLocker", () => {
722722
redisTest("Test configuration edge cases", { timeout: 15_000 }, async ({ redisOptions }) => {
723723
const logger = new Logger("RunLockTest", "debug");
724724

725-
// Test with maxRetries = 0
725+
// Test with maxAttempts = 0
726726
const redis1 = createRedisClient(redisOptions);
727727
const runLock1 = new RunLocker({
728728
redis: redis1,
729729
logger,
730730
tracer: trace.getTracer("RunLockTest"),
731731
retryConfig: {
732-
maxRetries: 0,
732+
maxAttempts: 0,
733733
baseDelay: 100,
734734
maxTotalWaitTime: 1000,
735735
},
736736
});
737737

738738
try {
739739
const config = runLock1.getRetryConfig();
740-
expect(config.maxRetries).toBe(0);
740+
expect(config.maxAttempts).toBe(0);
741741

742742
// Should work for successful acquisitions
743743
await runLock1.lock("test-lock", ["test-edge"], async () => {
@@ -754,7 +754,7 @@ describe("RunLocker", () => {
754754
logger,
755755
tracer: trace.getTracer("RunLockTest"),
756756
retryConfig: {
757-
maxRetries: 2,
757+
maxAttempts: 2,
758758
baseDelay: 1,
759759
maxDelay: 10,
760760
backoffMultiplier: 2.0,
@@ -785,7 +785,7 @@ describe("RunLocker", () => {
785785
logger,
786786
tracer: trace.getTracer("RunLockTest"),
787787
retryConfig: {
788-
maxRetries: 100, // High retry count
788+
maxAttempts: 100, // High retry count
789789
baseDelay: 100,
790790
maxTotalWaitTime: 500, // But low total wait time
791791
},
@@ -794,7 +794,7 @@ describe("RunLocker", () => {
794794
try {
795795
// Test that total wait time configuration is properly applied
796796
const config = runLock.getRetryConfig();
797-
expect(config.maxRetries).toBe(100);
797+
expect(config.maxAttempts).toBe(100);
798798
expect(config.maxTotalWaitTime).toBe(500);
799799
expect(config.baseDelay).toBe(100);
800800

@@ -946,7 +946,7 @@ describe("RunLocker", () => {
946946
tracer: trace.getTracer("RunLockTest"),
947947
duration: 30000,
948948
retryConfig: {
949-
maxRetries: 3,
949+
maxAttempts: 3,
950950
baseDelay: 100,
951951
maxDelay: 500,
952952
backoffMultiplier: 2.0,

0 commit comments

Comments
 (0)