Skip to content

Conversation

@rashidsp
Copy link
Contributor

@rashidsp rashidsp commented Sep 11, 2019

Summary

  • Fixed bug when blocking_timeout is set to default.
  • Block all APIs for the blocking_timeout period or datafile is not loaded successfulsy.
  • Updated doc string.
@rashidsp rashidsp requested a review from a team as a code owner September 11, 2019 14:53
@msohailhussain msohailhussain added the WIP Work in progress label Sep 11, 2019
@msohailhussain msohailhussain changed the title fix(blocking-timeout): fixed issue related to default blocking-timeout. fix(blocking-timeout): fixed issue related to default blocking-timeout. - WIP Sep 11, 2019
@coveralls
Copy link

coveralls commented Sep 11, 2019

Coverage Status

Coverage decreased (-0.02%) to 99.432% when pulling 3570990 on rashid/dfm-blocking-timeout into 7ab4650 on master.

)
end

def get_config
Copy link
Contributor

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.

Copy link
Contributor

@msohailhussain msohailhussain left a 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.

@msohailhussain msohailhussain removed the WIP Work in progress label Sep 11, 2019
@msohailhussain msohailhussain changed the title fix(blocking-timeout): fixed issue related to default blocking-timeout. - WIP fix(blocking-timeout): fixed issue related to default blocking-timeout. Sep 11, 2019
@msohailhussain msohailhussain changed the title fix(blocking-timeout): fixed issue related to default blocking-timeout. fix(blocking-api): fixed issue related to default blocking-timeout and blocking API methods. Sep 11, 2019
# 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
Copy link

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']
Copy link

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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

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:

@config_manager = if config_manager.respond_to?(:get_config)
config_manager
elsif sdk_key
HTTPProjectConfigManager.new(

@rashidsp rashidsp added WIP Work in progress and removed WIP Work in progress labels Sep 13, 2019
@mjc1283
Copy link

mjc1283 commented Sep 17, 2019

@msohailhussain Could you please review and approve if this looks good to you?

Copy link
Contributor

@msohailhussain msohailhussain left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjc1283 I think, better attribute name is stopped, since function name is stop. Do you suggest to rename it?
@rashidsp can you please add a comment here, if closed is true, then config is set to nil.

Copy link

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use config

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config or 'config'

# Returns a new optimizely instance.
#
# @param config_manager - Required ConfigManagerInterface Responds to get_config.
# @param config_manager - Required ConfigManagerInterface Responds to config method.
Copy link
Contributor

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.

@mjc1283 mjc1283 closed this Sep 19, 2019
@mjc1283 mjc1283 reopened this Sep 19, 2019
@mjc1283 mjc1283 merged commit 2d0b8b3 into master Sep 20, 2019
@rashidsp rashidsp deleted the rashid/dfm-blocking-timeout branch September 23, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants