Skip to content

Conversation

@rashidsp
Copy link
Contributor

Summary

This PR introduces config manager which polls for datafile after some interval and prepares project config based on it if it has updated.

@rashidsp rashidsp added the WIP Work in progress label Jun 17, 2019
@rashidsp rashidsp requested a review from msohailhussain June 17, 2019 15:55
@coveralls
Copy link

coveralls commented Jun 17, 2019

Coverage Status

Coverage decreased (-0.6%) to 99.315% when pulling 6eb5b12 on rashid/project-config-manager into dba2acc on dfm-complete.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 99.816% when pulling bb9dc7b on rashid/project-config-manager into dba2acc on dfm-complete.

# Implementation of ProjectConfigManager interface.
# Returns the stored ProjectConfig instance.

def initialize(datafile = nil, logger = nil, error_handler = nil, skip_json_validation = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Fallback projectconfigmanager should only take ProjectConfig. to create DatafileProjectConfig from datafile must be in any utils method.


private

def set_config(datafile)
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't really need it. Make it simple.


def running
# Check if polling thread is alive or not.
@polling_thread.alive?
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is auto_update?


def running
# Check if polling thread is alive or not.
@polling_thread.alive?
Copy link
Contributor

Choose a reason for hiding this comment

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

where stopping polling_thread

# Triggered as part of the thread which fetches the datafile and sleeps until next update interval.
while running
fetch_datafile
sleep @update_interval
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a check if we don't get response before our next schduled call, then no need to fetch again and as soon as get the response, then fetch datafile again immdiately.

@rashidsp rashidsp changed the base branch from dfm-complete to dfm-manager June 18, 2019 12:00
@rashidsp rashidsp changed the base branch from dfm-manager to dfm-complete June 18, 2019 12:03
Copy link
Contributor

@oakbani oakbani left a comment

Choose a reason for hiding this comment

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

Looks fine overall.

Enabled: false

Naming/AccessorMethodName:
Enabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than disabling this cop for entire project, use ruby standard practice and rename get_config to only config.
See the good example here https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Naming/AccessorMethodName

Otherwise, only exclude specific files under this cop and not the whole project

# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
Max: 8
Copy link
Contributor

Choose a reason for hiding this comment

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

exclude specific file under rubocop.yml instead of putting this in todo


# Get config for use by Optimizely.
# The config should be an instance of ProjectConfig.
def get_config(); end
Copy link
Contributor

Choose a reason for hiding this comment

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

we should raise a not implemented error here.

return
end

previous_revision = @config.revision if @config
Copy link
Contributor

Choose a reason for hiding this comment

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

The following code does not belong here. This should be part of polling config manager. In static we only initialize once with the provided datafile, that's it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Polling config manager overrides this method!


# Default config update interval of 5 minutes
# Minimum config update interval of 1 second
# Time in seconds before which request for datafile times out
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. Move these comments to a line above their explained constant


raise InvalidInputsError, 'Must provide at least one of sdk_key or url.' if sdk_key.nil? && url.nil?

return (url_template % sdk_key) unless url
Copy link
Contributor

Choose a reason for hiding this comment

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

can this raise an exception if url_template doesn't have a placeholder or more? or the type is different? If yes, we should catch it

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

Instead of working on a feature branch, please open up this PR against master!

require 'net/http'

module Optimizely
class PollingConfigManager < StaticConfigManager
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be derived from the StaticConfigManager.

The StaticConfigManager should only be a holder for the proejct config and should implement the BaseConfigManager

The PollingConfigManager is another implementation of the BaseConfigManager.

@msohailhussain
Copy link
Contributor

Instead of working on a feature branch, please open up this PR against master!

Yes Mike, it was supposed to be merge in master, This PR is actually not finalized yet.

@msohailhussain msohailhussain changed the base branch from dfm-complete to master June 21, 2019 02:28
@mikeproeng37
Copy link
Contributor

Closing this as we've decided to split up into separate PRs.

@rashidsp rashidsp deleted the rashid/project-config-manager branch July 17, 2019 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Work in progress

5 participants