diff --git a/AirshipFrameworkProxy.podspec b/AirshipFrameworkProxy.podspec index c3852a9..fe4cd1a 100644 --- a/AirshipFrameworkProxy.podspec +++ b/AirshipFrameworkProxy.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| - s.version = "11.1.0" + s.version = "11.2.0" s.name = "AirshipFrameworkProxy" s.summary = "Airship iOS mobile framework proxy" s.documentation_url = "https://docs.airship.com/platform/mobile" @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.swift_version = "5.0" s.source_files = "ios/AirshipFrameworkProxy/**/*.{h,m,swift}" - s.dependency 'Airship', "18.13.0" + s.dependency 'Airship', "18.14.0" s.source_files = 'ios/AirshipFrameworkProxyLoader/**/*.{swift,h,m,c,cc,mm,cpp}', 'ios/AirshipFrameworkProxy/**/*.{swift,h,m,c,cc,mm,cpp}' end diff --git a/Package.swift b/Package.swift index 2d07a95..4a0d2ec 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/urbanairship/ios-library.git", from: "18.13.0") + .package(url: "https://github.com/urbanairship/ios-library.git", from: "18.14.0") ], targets: [ .target( diff --git a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/proxies/FeatureFlagManagerProxy.kt b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/proxies/FeatureFlagManagerProxy.kt index 4ba0313..f89986a 100644 --- a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/proxies/FeatureFlagManagerProxy.kt +++ b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/proxies/FeatureFlagManagerProxy.kt @@ -2,14 +2,35 @@ package com.urbanairship.android.framework.proxy.proxies import com.urbanairship.featureflag.FeatureFlag import com.urbanairship.featureflag.FeatureFlagManager +import com.urbanairship.featureflag.FeatureFlagResultCache import com.urbanairship.json.JsonSerializable import com.urbanairship.json.JsonValue import com.urbanairship.json.jsonMapOf import com.urbanairship.json.requireField +import kotlin.time.Duration -public class FeatureFlagManagerProxy internal constructor(private val featureFlagManagerProvider: () -> FeatureFlagManager) { - public suspend fun flag(name: String): FeatureFlagProxy { - val flag = featureFlagManagerProvider().flag(name).getOrThrow() +public class FeatureFlagManagerProxy internal constructor( + private val featureFlagManagerProvider: () -> FeatureFlagManager, + public val resultCache: ResultCacheProxy = ResultCacheProxy { featureFlagManagerProvider().resultCache } +) { + + public class ResultCacheProxy internal constructor(private val cacheProvider: () -> FeatureFlagResultCache) { + + public suspend fun cache(flag: FeatureFlagProxy, ttl: Duration) { + cacheProvider().cache(flag.original, ttl) + } + + public suspend fun flag(name: String): FeatureFlagProxy? { + return cacheProvider().flag(name)?.let { FeatureFlagProxy(it) } + } + + public suspend fun removeCachedFlag(name: String) { + return cacheProvider().removeCachedFlag(name) + } + } + + public suspend fun flag(name: String, useResultCache: Boolean = true): FeatureFlagProxy { + val flag = featureFlagManagerProvider().flag(name, useResultCache).getOrThrow() return FeatureFlagProxy(flag) } diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 63ea9c9..ba3e224 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] # Airship -airshipProxy = '11.1.0' -airship = '18.5.0' +airshipProxy = '11.2.0' +airship = '18.6.0' # Gradle plugins androidGradlePlugin = '8.3.2' diff --git a/ios/AirshipFrameworkProxy/Proxies/AirshipFeatureFlagManagerProxy.swift b/ios/AirshipFrameworkProxy/Proxies/AirshipFeatureFlagManagerProxy.swift index d4f1891..5badf90 100644 --- a/ios/AirshipFrameworkProxy/Proxies/AirshipFeatureFlagManagerProxy.swift +++ b/ios/AirshipFrameworkProxy/Proxies/AirshipFeatureFlagManagerProxy.swift @@ -9,19 +9,51 @@ import AirshipCore import AirshipFeatureFlags #endif -public class AirshipFeatureFlagManagerProxy { - private let featureFlagManagerProvider: () throws -> FeatureFlagManager +public final class AirshipFeatureFlagManagerProxy: Sendable { + public final class ResultCacheProxy: Sendable { + private let cacheProvider: @Sendable () throws -> FeatureFlagResultCache + + init(cacheProvider: @Sendable @escaping () throws -> FeatureFlagResultCache) { + self.cacheProvider = cacheProvider + } + + private var cache: FeatureFlagResultCache { + get throws { try cacheProvider() } + } + + public func cache(flag: FeatureFlagProxy, ttl: TimeInterval) async throws { + try await self.cache.cache(flag: flag.original, ttl: ttl) + } + + public func flag(name: String) async throws -> FeatureFlagProxy? { + guard let flag = try await self.cache.flag(name: name) else { + return nil + } + return FeatureFlagProxy(flag: flag) + } + + public func removeCachedFlag(name: String) async throws { + try await self.cache.removeCachedFlag(name: name) + } + } + + private let featureFlagManagerProvider: @Sendable () throws -> FeatureFlagManager private var featureFlagManager: FeatureFlagManager { get throws { try featureFlagManagerProvider() } } - init(featureFlagManagerProvider: @escaping () throws -> FeatureFlagManager) { + init(featureFlagManagerProvider: @Sendable @escaping () throws -> FeatureFlagManager) { self.featureFlagManagerProvider = featureFlagManagerProvider + self.resultCache = ResultCacheProxy { + return try featureFlagManagerProvider().resultCache + } } - public func flag(name: String) async throws -> FeatureFlagProxy { - let flag = try await self.featureFlagManager.flag(name: name) + public let resultCache: ResultCacheProxy + + public func flag(name: String, useResultCache: Bool = true) async throws -> FeatureFlagProxy { + let flag = try await self.featureFlagManager.flag(name: name, useResultCache: useResultCache) return FeatureFlagProxy(flag: flag) } diff --git a/ios/Podfile b/ios/Podfile index c836cf8..38ff89b 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ target 'AirshipFrameworkProxy' do - pod 'Airship', '18.13.0' + pod 'Airship', '18.14.0' end target 'AirshipFrameworkProxyTests' do diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 75b93e0..3f67fd8 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,33 +1,33 @@ PODS: - - Airship (18.13.0): - - Airship/Automation (= 18.13.0) - - Airship/Basement (= 18.13.0) - - Airship/Core (= 18.13.0) - - Airship/FeatureFlags (= 18.13.0) - - Airship/MessageCenter (= 18.13.0) - - Airship/PreferenceCenter (= 18.13.0) - - Airship/Automation (18.13.0): + - Airship (18.14.0): + - Airship/Automation (= 18.14.0) + - Airship/Basement (= 18.14.0) + - Airship/Core (= 18.14.0) + - Airship/FeatureFlags (= 18.14.0) + - Airship/MessageCenter (= 18.14.0) + - Airship/PreferenceCenter (= 18.14.0) + - Airship/Automation (18.14.0): - Airship/Core - - Airship/Basement (18.13.0) - - Airship/Core (18.13.0): + - Airship/Basement (18.14.0) + - Airship/Core (18.14.0): - Airship/Basement - - Airship/FeatureFlags (18.13.0): + - Airship/FeatureFlags (18.14.0): - Airship/Core - - Airship/MessageCenter (18.13.0): + - Airship/MessageCenter (18.14.0): - Airship/Core - - Airship/PreferenceCenter (18.13.0): + - Airship/PreferenceCenter (18.14.0): - Airship/Core DEPENDENCIES: - - Airship (= 18.13.0) + - Airship (= 18.14.0) SPEC REPOS: trunk: - Airship SPEC CHECKSUMS: - Airship: bfe90d95c2b2bd0ea9ed5248a1337f124fe8abfe + Airship: 9667bffd8c715811e51c9d57e0fb5161bbb45533 -PODFILE CHECKSUM: f291ba6a8df67d15c53a5aa482d548d4b724e3e9 +PODFILE CHECKSUM: 1eea5e69b4e0a1593adfeefecb198172841000f8 -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2