- Notifications
You must be signed in to change notification settings - Fork 28
fix(blocking-api): fixed issue related to default blocking-timeout and blocking API methods. #202
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
Conversation
| ) | ||
| end | ||
| | ||
| def get_config |
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.
I think, this should be defined in the projectconfigmanager as an abstract method. right now i can see config is defined in the projectconfig manager.
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.
please respond to get_config, rest of the stuff will review after that.
| # we simply return config. | ||
| # If it is not, we wait and block maximum for @blocking_timeout. | ||
| # If thread is not running, we fetch the datafile and update config. | ||
| return nil if @closed == true |
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.
Why do we have to return nil in this case? Is there a problem with just returning the current @config? Also, why @closed == true instead of @closed?
| "Blocking timeout is not provided. Defaulting to #{Helpers::Constants::CONFIG_MANAGER['DEFAULT_BLOCKING_TIMEOUT']} seconds." | ||
| ) | ||
| @polling_interval = Helpers::Constants::CONFIG_MANAGER['DEFAULT_BLOCKING_TIMEOUT'] | ||
| @blocking_timeout = Helpers::Constants::CONFIG_MANAGER['DEFAULT_BLOCKING_TIMEOUT'] |
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.
Please ensure that there is test coverage that would have revealed these places where it should have been @blocking_timeout, but was actually @polling_interval.
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.
Done
| end | ||
| | ||
| def get_config | ||
| def config |
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.
why you are defining config not get_config, unable to understand.
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.
Following ruby's convention.
Please view rubocop's rule https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Naming/AccessorMethodName
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.
I stumpled upon this, too. Not even your own StaticProjectConfigManager is using get_config which makes it unusable here:
Lines 85 to 88 in 31e93c7
| @config_manager = if config_manager.respond_to?(:get_config) | |
| config_manager | |
| elsif sdk_key | |
| HTTPProjectConfigManager.new( |
| @msohailhussain Could you please review and approve if this looks good to you? |
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.
lgtm. please address minor nits.
| # we simply return config. | ||
| # If it is not, we wait and block maximum for @blocking_timeout. | ||
| # If thread is not running, we fetch the datafile and update config. | ||
| return @config if @closed |
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.
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.
@msohailhussain I agree that stopped is a better attribute name.
README.md Outdated
| When the `datafile` is given then it will be used initially before any update. | ||
| 2. Initialize Optimizely by providing a Config Manager that implements a 'get_config' method. You can customize our `HTTPConfigManager` as needed. | ||
| 2. Initialize Optimizely by providing a Config Manager that implements a 'config' method. You can customize our `HTTPConfigManager` as needed. |
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.
Please use config
lib/optimizely/helpers/constants.rb Outdated
| CONFIG_MANAGER = { | ||
| 'DATAFILE_URL_TEMPLATE' => 'https://cdn.optimizely.com/datafiles/%s.json', | ||
| # Default time in seconds to block the get_config call until config has been initialized. | ||
| # Default time in seconds to block the config method call until config has been initialized. |
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.
config or 'config'
lib/optimizely/optimizely_factory.rb Outdated
| # Returns a new optimizely instance. | ||
| # | ||
| # @param config_manager - Required ConfigManagerInterface Responds to get_config. | ||
| # @param config_manager - Required ConfigManagerInterface Responds to config method. |
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.
please single quote. am saying config should be more focused as method name.
Summary
blocking_timeoutis set to default.blocking_timeoutperiod or datafile is not loaded successfulsy.