File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 1616
1717import Foundation
1818
19- let DEFAULT_CMAB_CACHE_TIMEOUT = 30 * 60 // 30 minutes
20- let DEFAULT_CMAB_CACHE_SIZE = 100
21-
2219enum CmabClientError : Error , Equatable {
2320 case fetchFailed( String )
2421 case invalidResponse
@@ -51,8 +48,6 @@ protocol CmabClient {
5148 )
5249}
5350
54- let CMAB_END_POINT = " https://prediction.cmab.optimizely.com/predict "
55-
5651class DefaultCmabClient : CmabClient {
5752 let session : URLSession
5853 let retryConfig : CmabRetryConfig
@@ -69,7 +64,7 @@ class DefaultCmabClient: CmabClient {
6964 self . session = session
7065 self . retryConfig = retryConfig
7166 self . maxWaitTime = maxWaitTime
72- self . predictionEndpoint = predictionEndpoint ?? CMAB_END_POINT
67+ self . predictionEndpoint = predictionEndpoint ?? CMAB_PREDICTION_END_POINT
7368 }
7469
7570 func fetchDecision(
Original file line number Diff line number Diff line change 1616
1717import Foundation
1818
19+ let DEFAULT_CMAB_CACHE_TIMEOUT = 30 * 60 // 30 minutes
20+ let DEFAULT_CMAB_CACHE_SIZE = 100
21+ let CMAB_PREDICTION_END_POINT = " https://prediction.cmab.optimizely.com/predict "
22+
1923/// Configuration for CMAB (Contextual Multi-Armed Bandit) service
2024public struct CmabConfig {
2125 /// The maximum size of CMAB decision cache
@@ -37,14 +41,14 @@ public struct CmabConfig {
3741 self . cacheTimeoutInSecs = cacheTimeoutInSecs
3842 // Sanitize and validate endpoint
3943 if let endpoint = predictionEndpoint? . trimmingCharacters ( in: . whitespaces) , !endpoint. isEmpty {
40- // Remove all trailing slashes
44+ // Remove trailing slashes
4145 var sanitized = endpoint
42- while sanitized. hasSuffix ( " / " ) {
46+ if sanitized. hasSuffix ( " / " ) {
4347 sanitized = String ( sanitized. dropLast ( ) )
4448 }
4549 self . predictionEndpoint = sanitized
4650 } else {
47- self . predictionEndpoint = CMAB_END_POINT
51+ self . predictionEndpoint = CMAB_PREDICTION_END_POINT
4852 }
4953 }
5054}
You can’t perform that action at this time.
0 commit comments