- 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
[FSSDK-12012] expose prediction endpoint #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FSSDK-12012] expose prediction endpoint #427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for configurable CMAB prediction endpoints, allowing users to specify custom endpoint URLs instead of being hard-coded to the default Optimizely endpoint. This is useful for scenarios like proxying requests through custom infrastructure or using alternative prediction services.
Key changes:
- Refactored the global mutable 
CMABPredictionEndpointvariable into an instance-level configuration field - Added 
PredictionEndpointfield to CMAB configuration structs throughout the codebase - Updated tests to use the new configuration approach instead of mutating global state
 
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description | 
|---|---|
| pkg/cmab/config.go | Added DefaultPredictionEndpointTemplate constant and PredictionEndpoint field to Config struct | 
| pkg/cmab/client.go | Replaced global CMABPredictionEndpoint variable with instance field and DefaultPredictionEndpoint constant; updated ClientOptions to include PredictionEndpoint | 
| pkg/cmab/client_test.go | Refactored tests to use PredictionEndpoint option instead of mutating global state; added new tests for custom endpoint functionality | 
| pkg/decision/experiment_cmab_service.go | Added logic to handle PredictionEndpoint configuration with appropriate fallback to defaults | 
| pkg/client/factory.go | Added PredictionEndpoint field to public CmabConfig struct and its conversion logic | 
| pkg/client/factory_test.go | Added tests for PredictionEndpoint configuration at the client factory level | 
Comments suppressed due to low confidence (1)
pkg/cmab/config.go:60
- The 
NewDefaultConfigfunction does not set thePredictionEndpointfield despite it being part of theConfigstruct. This means users calling this function won't get the default prediction endpoint. AddPredictionEndpoint: DefaultPredictionEndpointto the returned Config. 
// NewDefaultConfig creates a Config with default values
func NewDefaultConfig() Config {
	return Config{
		CacheSize:   DefaultCacheSize,
		CacheTTL:    DefaultCacheTTL,
		HTTPTimeout: DefaultHTTPTimeout,
		RetryConfig: &RetryConfig{
			MaxRetries: DefaultMaxRetries,
		},
	}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds CMAB endpoint.
- Renamed field from PredictionEndpoint to PredictionEndpointTemplate for clarity - Updated all references across client, config, factory, and tests - Removed redundant constant definition from config.go - Removed setting predictionEndpoint in NewExperimentCmabService when config is nil - Changed test endpoint from endpoint.com to example.com (avoid real domain) - All tests passing
Jira ticket:
https://optimizely-ext.atlassian.net/browse/FSSDK-12012