-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
RedisConnection.Configuration.defaultPort
thread safe (#81)
`RedisConnection.Configuration.defaultPort` is currently unprotected shared mutable state. To ensure thread safety this patch adds an atomic to back this property. Since setting the `defaultPort` doesn't make much sense for adopters, we deprecate the setter. Lastly we mark `RedisConnection.Configuration` as `Sendable`.
- Loading branch information
1 parent
5c8a788
commit 43ea6af
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Tests/RediStackTests/RedisConnection+ConfigurationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the RediStack open source project | ||
// | ||
// Copyright (c) 2023 RediStack project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of RediStack project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import RediStack | ||
import XCTest | ||
|
||
final class RedisConnection_ConfigurationTest: XCTestCase { | ||
|
||
func testGetDefaultRedisPort() { | ||
XCTAssertEqual(RedisConnection.Configuration.defaultPort, 6379) | ||
} | ||
|
||
@available(*, deprecated, message: "Testing deprecated functionality") | ||
func testGetAndSetTheDefaultRedisPort() { | ||
XCTAssertEqual(RedisConnection.Configuration.defaultPort, 6379) | ||
RedisConnection.Configuration.defaultPort = 1234 | ||
XCTAssertEqual(RedisConnection.Configuration.defaultPort, 1234) | ||
|
||
// reset the default port | ||
RedisConnection.Configuration.defaultPort = 6379 | ||
} | ||
} | ||
|