Skip to content

Commit

Permalink
Deprecate ...Sync() methods (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein authored Apr 5, 2023
1 parent 1d080a1 commit bafa094
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ConfigCat.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "ConfigCat"
spec.version = "9.3.0"
spec.version = "9.4.0"
spec.summary = "ConfigCat Swift SDK"
spec.swift_version = "4.2"

Expand Down
2 changes: 1 addition & 1 deletion ConfigCat.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator app
SWIFT_VERSION = 4.2

// ConfigCat SDK version
MARKETING_VERSION = 9.3.0
MARKETING_VERSION = 9.4.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If you want to use ConfigCat in a [SwiftPM](https://swift.org/package-manager/)

``` swift
dependencies: [
.package(url: "https://github.com/configcat/swift-sdk", from: "9.3.0")
.package(url: "https://github.com/configcat/swift-sdk", from: "9.4.0")
]
```

Expand Down
17 changes: 16 additions & 1 deletion Sources/ConfigCat/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extension ConfigCatClient {
#endif

// Synchronous extensions

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getValue() instead.")
public func getValueSync<Value>(for key: String, defaultValue: Value, user: ConfigCatUser? = nil) -> Value {
let semaphore = DispatchSemaphore(value: 0)
var result: Value?
Expand All @@ -168,6 +168,7 @@ extension ConfigCatClient {
return result ?? defaultValue
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getValueDetails() instead.")
public func getValueDetailsSync<Value>(for key: String, defaultValue: Value, user: ConfigCatUser? = nil) -> TypedEvaluationDetails<Value> {
let semaphore = DispatchSemaphore(value: 0)
var result: TypedEvaluationDetails<Value>?
Expand All @@ -179,6 +180,7 @@ extension ConfigCatClient {
return result ?? TypedEvaluationDetails<Value>.fromError(key: key, value: defaultValue, error: String(format: "Could not get the evaluation details for '%@'.", key), user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getAllValueDetails() instead.")
@objc public func getAllValueDetailsSync(user: ConfigCatUser? = nil) -> [EvaluationDetails] {
let semaphore = DispatchSemaphore(value: 0)
var result = [EvaluationDetails]()
Expand All @@ -190,6 +192,7 @@ extension ConfigCatClient {
return result
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getAllKeys() instead.")
@objc public func getAllKeysSync() -> [String] {
let semaphore = DispatchSemaphore(value: 0)
var result = [String]()
Expand Down Expand Up @@ -225,6 +228,7 @@ extension ConfigCatClient {
return result
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getKeyAndValue() instead.")
@objc public func getKeyAndValueSync(for variationId: String) -> KeyValue? {
let semaphore = DispatchSemaphore(value: 0)
var result: KeyValue?
Expand All @@ -236,6 +240,7 @@ extension ConfigCatClient {
return result
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getAllValues() instead.")
@objc public func getAllValuesSync(user: ConfigCatUser? = nil) -> [String: Any] {
let semaphore = DispatchSemaphore(value: 0)
var result = [String: Any]()
Expand All @@ -256,6 +261,7 @@ extension ConfigCatClient {
semaphore.wait()
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous forceRefresh() instead.")
@discardableResult
@objc public func forceRefreshSync() -> RefreshResult {
let semaphore = DispatchSemaphore(value: 0)
Expand All @@ -268,38 +274,47 @@ extension ConfigCatClient {
return refreshResult ?? RefreshResult(success: false)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getStringValue() instead.")
@objc public func getStringValueSync(for key: String, defaultValue: String, user: ConfigCatUser?) -> String {
getValueSync(for: key, defaultValue: defaultValue, user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getIntValue() instead.")
@objc public func getIntValueSync(for key: String, defaultValue: Int, user: ConfigCatUser?) -> Int {
getValueSync(for: key, defaultValue: defaultValue, user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getDoubleValue() instead.")
@objc public func getDoubleValueSync(for key: String, defaultValue: Double, user: ConfigCatUser?) -> Double {
getValueSync(for: key, defaultValue: defaultValue, user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getBoolValue() instead.")
@objc public func getBoolValueSync(for key: String, defaultValue: Bool, user: ConfigCatUser?) -> Bool {
getValueSync(for: key, defaultValue: defaultValue, user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getAnyValue() instead.")
@objc public func getAnyValueSync(for key: String, defaultValue: Any, user: ConfigCatUser?) -> Any {
getValueSync(for: key, defaultValue: defaultValue, user: user)
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getStringValueDetails() instead.")
@objc public func getStringValueDetailsSync(for key: String, defaultValue: String, user: ConfigCatUser?) -> StringEvaluationDetails {
getValueDetailsSync(for: key, defaultValue: defaultValue, user: user).toStringDetails()
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getIntValueDetails() instead.")
@objc public func getIntValueDetailsSync(for key: String, defaultValue: Int, user: ConfigCatUser?) -> IntEvaluationDetails {
getValueDetailsSync(for: key, defaultValue: defaultValue, user: user).toIntDetails()
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getDoubleValueDetails() instead.")
@objc public func getDoubleValueDetailsSync(for key: String, defaultValue: Double, user: ConfigCatUser?) -> DoubleEvaluationDetails {
getValueDetailsSync(for: key, defaultValue: defaultValue, user: user).toDoubleDetails()
}

@available(*, deprecated, message: "This method can produce thread priority inversion due to the usage of DispatchSemaphore for call synchronization. It will be removed in a future major version. Please use the asynchronous getBoolValueDetails() instead.")
@objc public func getBoolValueDetailsSync(for key: String, defaultValue: Bool, user: ConfigCatUser?) -> BoolEvaluationDetails {
getValueDetailsSync(for: key, defaultValue: defaultValue, user: user).toBoolDetails()
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/ConfigCat/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extension Date {
}

class Constants {
static let version: String = "9.3.0"
static let version: String = "9.4.0"
static let configJsonName: String = "config_v5"
static let globalBaseUrl: String = "https://cdn-global.configcat.com"
static let euOnlyBaseUrl: String = "https://cdn-eu.configcat.com"
}
}

0 comments on commit bafa094

Please sign in to comment.