From e02ed7ed0a70434c5ddf53ac521c7f94476e4c02 Mon Sep 17 00:00:00 2001 From: anitarua Date: Wed, 21 Aug 2024 12:46:39 -0700 Subject: [PATCH] rename to FixedTimeoutRetryStrategy --- ...rategy.ts => fixed-timeout-retry-strategy.ts} | 16 ++++++++-------- .../src/config/storage-configurations.ts | 4 ++-- .../internal/grpc/client-timeout-interceptor.ts | 4 ++-- .../test/unit/storage-retry.test.ts | 10 ++++------ 4 files changed, 16 insertions(+), 18 deletions(-) rename packages/client-sdk-nodejs/src/config/retry/{storage-default-retry-strategy.ts => fixed-timeout-retry-strategy.ts} (87%) diff --git a/packages/client-sdk-nodejs/src/config/retry/storage-default-retry-strategy.ts b/packages/client-sdk-nodejs/src/config/retry/fixed-timeout-retry-strategy.ts similarity index 87% rename from packages/client-sdk-nodejs/src/config/retry/storage-default-retry-strategy.ts rename to packages/client-sdk-nodejs/src/config/retry/fixed-timeout-retry-strategy.ts index 08c798354..c5465f624 100644 --- a/packages/client-sdk-nodejs/src/config/retry/storage-default-retry-strategy.ts +++ b/packages/client-sdk-nodejs/src/config/retry/fixed-timeout-retry-strategy.ts @@ -7,10 +7,10 @@ import { MomentoLoggerFactory, MomentoLogger, DefaultMomentoLoggerFactory, -} from '../../'; +} from '../..'; import {DefaultStorageEligibilityStrategy} from './storage-default-eligibility-strategy'; -export interface DefaultStorageRetryStrategyProps { +export interface FixedTimeoutRetryStrategyProps { loggerFactory: MomentoLoggerFactory; eligibilityStrategy?: EligibilityStrategy; @@ -21,13 +21,13 @@ export interface DefaultStorageRetryStrategyProps { responseDataReceivedTimeoutMillis?: number; } -export class DefaultStorageRetryStrategy implements RetryStrategy { +export class FixedTimeoutRetryStrategy implements RetryStrategy { private readonly logger: MomentoLogger; private readonly eligibilityStrategy: EligibilityStrategy; private readonly retryDelayIntervalMillis: number; private readonly responseDataReceivedTimeoutMillis: number; - constructor(props: DefaultStorageRetryStrategyProps) { + constructor(props: FixedTimeoutRetryStrategyProps) { this.logger = props.loggerFactory.getLogger(this); this.eligibilityStrategy = props.eligibilityStrategy ?? @@ -60,11 +60,11 @@ export class DefaultStorageRetryStrategy implements RetryStrategy { } } -export class DefaultStorageRetryStrategyFactory { +export class FixedTimeoutRetryStrategyFactory { static getRetryStrategy( - props?: DefaultStorageRetryStrategyProps - ): DefaultStorageRetryStrategy { - return new DefaultStorageRetryStrategy({ + props?: FixedTimeoutRetryStrategyProps + ): FixedTimeoutRetryStrategy { + return new FixedTimeoutRetryStrategy({ loggerFactory: props?.loggerFactory ?? new DefaultMomentoLoggerFactory(), eligibilityStrategy: props?.eligibilityStrategy, retryDelayIntervalMillis: props?.retryDelayIntervalMillis, diff --git a/packages/client-sdk-nodejs/src/config/storage-configurations.ts b/packages/client-sdk-nodejs/src/config/storage-configurations.ts index 458ae5989..7ad9b09d9 100644 --- a/packages/client-sdk-nodejs/src/config/storage-configurations.ts +++ b/packages/client-sdk-nodejs/src/config/storage-configurations.ts @@ -8,7 +8,7 @@ import { StaticStorageGrpcConfiguration, StaticStorageTransportStrategy, } from './transport/storage'; -import {DefaultStorageRetryStrategy} from './retry/storage-default-retry-strategy'; +import {FixedTimeoutRetryStrategy} from './retry/fixed-timeout-retry-strategy'; import {RetryStrategy} from './retry/retry-strategy'; const defaultLoggerFactory: MomentoLoggerFactory = @@ -17,7 +17,7 @@ const defaultLoggerFactory: MomentoLoggerFactory = function defaultRetryStrategy( loggerFactory: MomentoLoggerFactory ): RetryStrategy { - return new DefaultStorageRetryStrategy({ + return new FixedTimeoutRetryStrategy({ loggerFactory: loggerFactory, }); } diff --git a/packages/client-sdk-nodejs/src/internal/grpc/client-timeout-interceptor.ts b/packages/client-sdk-nodejs/src/internal/grpc/client-timeout-interceptor.ts index 64acfee50..b58a0683d 100644 --- a/packages/client-sdk-nodejs/src/internal/grpc/client-timeout-interceptor.ts +++ b/packages/client-sdk-nodejs/src/internal/grpc/client-timeout-interceptor.ts @@ -1,7 +1,7 @@ import {MomentoLogger, MomentoLoggerFactory} from '@gomomento/sdk-core'; import {InterceptingCall, Interceptor, status} from '@grpc/grpc-js'; import {RetryStrategy} from '../../config/retry/retry-strategy'; -import {DefaultStorageRetryStrategy} from '../../config/retry/storage-default-retry-strategy'; +import {FixedTimeoutRetryStrategy} from '../../config/retry/fixed-timeout-retry-strategy'; import {DefaultMomentoLoggerFactory} from '../../config/logging/default-momento-logger'; // Determine which retry strategy is specified in the configuration @@ -13,7 +13,7 @@ export const ClientTimeoutInterceptor = ( ): Interceptor => { if ( retryStrategy !== undefined && - retryStrategy instanceof DefaultStorageRetryStrategy + retryStrategy instanceof FixedTimeoutRetryStrategy ) { const responseDataReceivedTimeoutMs = retryStrategy.getResponseDataReceivedTimeoutMillis(); diff --git a/packages/client-sdk-nodejs/test/unit/storage-retry.test.ts b/packages/client-sdk-nodejs/test/unit/storage-retry.test.ts index 23b014c2a..466f2aa18 100644 --- a/packages/client-sdk-nodejs/test/unit/storage-retry.test.ts +++ b/packages/client-sdk-nodejs/test/unit/storage-retry.test.ts @@ -11,7 +11,7 @@ import { StaticStorageTransportStrategy, StorageClientConfiguration, } from '../../src'; -import {DefaultStorageRetryStrategyFactory} from '../../src/config/retry/storage-default-retry-strategy'; +import {FixedTimeoutRetryStrategyFactory} from '../../src/config/retry/fixed-timeout-retry-strategy'; import {Metadata, StatusObject} from '@grpc/grpc-js'; describe('storage configuration', () => { @@ -22,11 +22,9 @@ describe('storage configuration', () => { const testTransportStrategy = new StaticStorageTransportStrategy({ grpcConfiguration: testGrpcConfiguration, }); - const testRetryStrategy = DefaultStorageRetryStrategyFactory.getRetryStrategy( - { - loggerFactory: testLoggerFactory, - } - ); + const testRetryStrategy = FixedTimeoutRetryStrategyFactory.getRetryStrategy({ + loggerFactory: testLoggerFactory, + }); const testConfiguration = new StorageClientConfiguration({ loggerFactory: testLoggerFactory, transportStrategy: testTransportStrategy,