Class: Optimizely::DefaultCmabService
- Inherits:
-
Object
- Object
- Optimizely::DefaultCmabService
- Defined in:
- lib/optimizely/cmab/cmab_service.rb
Overview
Default CMAB service implementation
Constant Summary collapse
- NUM_LOCK_STRIPES =
Initializes a new instance of the CmabService.
1000
Instance Method Summary collapse
- #get_decision(project_config, user_context, rule_id, options) ⇒ Object
-
#initialize(cmab_cache, cmab_client, logger = nil) ⇒ DefaultCmabService
constructor
A new instance of DefaultCmabService.
Constructor Details
#initialize(cmab_cache, cmab_client, logger = nil) ⇒ DefaultCmabService
Returns a new instance of DefaultCmabService.
49 50 51 52 53 54 |
# File 'lib/optimizely/cmab/cmab_service.rb', line 49 def initialize(cmab_cache, cmab_client, logger = nil) @cmab_cache = cmab_cache @cmab_client = cmab_client @logger = logger || NoOpLogger.new @locks = Array.new(NUM_LOCK_STRIPES) { Mutex.new } end |
Instance Method Details
#get_decision(project_config, user_context, rule_id, options) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/optimizely/cmab/cmab_service.rb', line 56 def get_decision(project_config, user_context, rule_id, ) lock_index = get_lock_index(user_context.user_id, rule_id) @locks[lock_index].synchronize do get_decision_impl(project_config, user_context, rule_id, ) end end |