Skip to content

Commit

Permalink
rename to FixedTimeoutRetryStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Aug 21, 2024
1 parent e82e54d commit e02ed7e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 ??
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -17,7 +17,7 @@ const defaultLoggerFactory: MomentoLoggerFactory =
function defaultRetryStrategy(
loggerFactory: MomentoLoggerFactory
): RetryStrategy {
return new DefaultStorageRetryStrategy({
return new FixedTimeoutRetryStrategy({
loggerFactory: loggerFactory,
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,7 +13,7 @@ export const ClientTimeoutInterceptor = (
): Interceptor => {
if (
retryStrategy !== undefined &&
retryStrategy instanceof DefaultStorageRetryStrategy
retryStrategy instanceof FixedTimeoutRetryStrategy
) {
const responseDataReceivedTimeoutMs =
retryStrategy.getResponseDataReceivedTimeoutMillis();
Expand Down
10 changes: 4 additions & 6 deletions packages/client-sdk-nodejs/test/unit/storage-retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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,
Expand Down

0 comments on commit e02ed7e

Please sign in to comment.