@@ -21,12 +21,13 @@ import { extractEventProcessor } from "./event_processor/event_processor_factory
2121import { extractOdpManager } from "./odp/odp_manager_factory" ;
2222import { extractVuidManager } from "./vuid/vuid_manager_factory" ;
2323import { RequestHandler } from "./utils/http_request_handler/http" ;
24- import { CLIENT_VERSION , DEFAULT_CMAB_CACHE_SIZE , DEFAULT_CMAB_CACHE_TIMEOUT , JAVASCRIPT_CLIENT_ENGINE } from "./utils/enums" ;
24+ import { CLIENT_VERSION , DEFAULT_CMAB_BACKOFF_MS , DEFAULT_CMAB_CACHE_SIZE , DEFAULT_CMAB_CACHE_TIMEOUT_MS , DEFAULT_CMAB_RETRIES , JAVASCRIPT_CLIENT_ENGINE } from "./utils/enums" ;
2525import Optimizely from "./optimizely" ;
2626import { DefaultCmabClient } from "./core/decision_service/cmab/cmab_client" ;
2727import { CmabCacheValue , DefaultCmabService } from "./core/decision_service/cmab/cmab_service" ;
2828import { InMemoryLruCache } from "./utils/cache/in_memory_lru_cache" ;
2929import { transformCache , CacheWithRemove } from "./utils/cache/cache" ;
30+ import { ConstantBackoff , ExponentialBackoff } from "./utils/repeater/repeater" ;
3031
3132export type OptimizelyFactoryConfig = Config & {
3233 requestHandler : RequestHandler ;
@@ -53,13 +54,17 @@ export const getOptimizelyInstance = (config: OptimizelyFactoryConfig): Optimize
5354
5455 const cmabClient = new DefaultCmabClient ( {
5556 requestHandler,
57+ retryConfig : {
58+ maxRetries : DEFAULT_CMAB_RETRIES ,
59+ backoffProvider : ( ) => new ConstantBackoff ( DEFAULT_CMAB_BACKOFF_MS ) ,
60+ }
5661 } ) ;
5762
5863 const cmabCache : CacheWithRemove < CmabCacheValue > = config . cmab ?. cache ?
5964 transformCache ( config . cmab . cache , ( value ) => JSON . parse ( value ) , ( value ) => JSON . stringify ( value ) ) :
6065 ( ( ) => {
6166 const cacheSize = config . cmab ?. cacheSize || DEFAULT_CMAB_CACHE_SIZE ;
62- const cacheTtl = config . cmab ?. cacheTtl || DEFAULT_CMAB_CACHE_TIMEOUT ;
67+ const cacheTtl = config . cmab ?. cacheTtl || DEFAULT_CMAB_CACHE_TIMEOUT_MS ;
6368 return new InMemoryLruCache < CmabCacheValue > ( cacheSize , cacheTtl ) ;
6469 } ) ( ) ;
6570
0 commit comments