From 0617ec02e58c1949d0f409d7f609008a67b663ef Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Tue, 14 Nov 2023 15:30:50 -0800 Subject: [PATCH] chore: use enums to namespace prebuilt configurations --- .../momento/config/TopicConfigurations.swift | 24 +++++++++++++------ .../client_sdk_swiftTests.swift | 9 ++++--- Tests/client-sdk-swiftTests/configTests.swift | 7 ++++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Sources/momento/config/TopicConfigurations.swift b/Sources/momento/config/TopicConfigurations.swift index 0b2c347..cbd797b 100644 --- a/Sources/momento/config/TopicConfigurations.swift +++ b/Sources/momento/config/TopicConfigurations.swift @@ -1,12 +1,22 @@ // Prebuilt configurations for Momento Topics clients -public class Default: TopicClientConfiguration { - static func latest() -> TopicClientConfiguration { - return TopicClientConfiguration( - loggerFactory: DefaultMomentoLoggerFactory(), - transportStrategy: StaticTransportStrategy( - grpcConfig: StaticGrpcConfiguration(deadline: 15.0) +enum TopicConfigurations { + + enum Default { + + static func latest() -> TopicClientConfiguration { + return TopicClientConfiguration( + loggerFactory: DefaultMomentoLoggerFactory(), + transportStrategy: StaticTransportStrategy( + grpcConfig: StaticGrpcConfiguration(deadline: 15.0) + ) ) - ) + } + + static func v1() -> TopicClientConfiguration { + return latest() + } + } + } diff --git a/Tests/client-sdk-swiftTests/client_sdk_swiftTests.swift b/Tests/client-sdk-swiftTests/client_sdk_swiftTests.swift index 356c734..4f96956 100644 --- a/Tests/client-sdk-swiftTests/client_sdk_swiftTests.swift +++ b/Tests/client-sdk-swiftTests/client_sdk_swiftTests.swift @@ -12,7 +12,10 @@ final class client_sdk_swiftTests: XCTestCase { func testTopicClientPublishes() async throws { let creds = try CredentialProvider.fromEnvironmentVariable(envVariableName: "MOMENTO_API_KEY") - let client = TopicClient(configuration: Default.latest(), credentialProvider: creds) + let client = TopicClient( + configuration: TopicConfigurations.Default.latest(), + credentialProvider: creds + ) XCTAssertNotNil(client) let invalidCacheNameResp = await client.publish( @@ -58,7 +61,7 @@ final class client_sdk_swiftTests: XCTestCase { func testTopicClientSubscribes() async throws { let creds = try CredentialProvider.fromEnvironmentVariable(envVariableName: "MOMENTO_API_KEY") - let client = TopicClient(configuration: Default.latest(), credentialProvider: creds) + let client = TopicClient(configuration: TopicConfigurations.Default.latest(), credentialProvider: creds) XCTAssertNotNil(client) let invalidCacheNameResp = await client.subscribe( @@ -101,7 +104,7 @@ final class client_sdk_swiftTests: XCTestCase { func testTopicClientPublishesAndSubscribes() async throws { let creds = try CredentialProvider.fromEnvironmentVariable(envVariableName: "MOMENTO_API_KEY") - let client = TopicClient(configuration: Default.latest(), credentialProvider: creds) + let client = TopicClient(configuration: TopicConfigurations.Default.latest(), credentialProvider: creds) XCTAssertNotNil(client) let subResp = await client.subscribe( diff --git a/Tests/client-sdk-swiftTests/configTests.swift b/Tests/client-sdk-swiftTests/configTests.swift index 336a8e7..b6227ae 100644 --- a/Tests/client-sdk-swiftTests/configTests.swift +++ b/Tests/client-sdk-swiftTests/configTests.swift @@ -7,7 +7,10 @@ final class configTests: XCTestCase { let creds = try CredentialProvider.fromEnvironmentVariable(envVariableName: "MOMENTO_API_KEY") XCTAssertNotNil(creds) - let client = TopicClient(configuration: Default.latest(), credentialProvider: creds) + let client = TopicClient( + configuration: TopicConfigurations.Default.latest(), + credentialProvider: creds + ) XCTAssertNotNil(client) } @@ -22,7 +25,7 @@ final class configTests: XCTestCase { func testTimeoutForImpossibleDeadline() async throws { let creds = try CredentialProvider.fromEnvironmentVariable(envVariableName: "MOMENTO_API_KEY") - let configuration = Default.latest().withClientTimeout(timeout: 0.001) + let configuration = TopicConfigurations.Default.latest().withClientTimeout(timeout: 0.001) let client = TopicClient(configuration: configuration, credentialProvider: creds) // TODO: use test framework's setup and teardown methods to create and delete caches for use with tests let pubResp = await client.publish(