Skip to content

Adjusting config manager to support a Sync method #99

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

Merged
merged 5 commits into from
Sep 12, 2019

Conversation

aliabbasrizvi
Copy link
Contributor

Introducing this method will allow some advanced use cases like requesting datafile be updated on demand.

t := time.NewTicker(cm.pollingInterval)
for {
select {
case <-t.C:
update()
cm.Sync([]byte{})
Copy link
Contributor

Choose a reason for hiding this comment

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

keep private, sync instead of Sync

projectConfig, err := datafileprojectconfig.NewDatafileProjectConfig(payload)
if err != nil {
cmLogger.Error("failed to create project config", err)
func (cm *PollingProjectConfigManager) Sync(datafile []byte) {
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 comment, otherwise linters will complain
comment has to be like // SyncConfig .......

Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

understanding the motives, lgtm

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.

Mostly ok, have a suggestion

func (cm *PollingProjectConfigManager) SyncConfig(datafile []byte) {
var e error
var code int
if len(datafile) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do a nil check and pass in nil from the ticker sync call below? It is more accurate to treat it as nil than an empty byte array

Copy link
Contributor

Choose a reason for hiding this comment

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

we will be able to pass both, so we need to check for len of datafile when it's not nil, and also for nil itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going by @pawels-optimizely 's comment and leaving this as is.

@aliabbasrizvi aliabbasrizvi force-pushed the ali/modify_config_manager branch from 2fbe431 to a3ac5b3 Compare September 11, 2019 23:58
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.

Ship it

@aliabbasrizvi aliabbasrizvi merged commit 02f4bbd into master Sep 12, 2019
@aliabbasrizvi aliabbasrizvi deleted the ali/modify_config_manager branch September 12, 2019 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants