-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
optimizely/config/polling_manager.go
Outdated
t := time.NewTicker(cm.pollingInterval) | ||
for { | ||
select { | ||
case <-t.C: | ||
update() | ||
cm.Sync([]byte{}) |
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.
keep private, sync instead of Sync
optimizely/config/polling_manager.go
Outdated
projectConfig, err := datafileprojectconfig.NewDatafileProjectConfig(payload) | ||
if err != nil { | ||
cmLogger.Error("failed to create project config", err) | ||
func (cm *PollingProjectConfigManager) Sync(datafile []byte) { |
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 add a comment, otherwise linters will complain
comment has to be like // SyncConfig .......
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.
understanding the motives, lgtm
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.
Mostly ok, have a suggestion
func (cm *PollingProjectConfigManager) SyncConfig(datafile []byte) { | ||
var e error | ||
var code int | ||
if len(datafile) == 0 { |
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.
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
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.
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
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 am going by @pawels-optimizely 's comment and leaving this as is.
…ivate-->start and some other terms
2fbe431
to
a3ac5b3
Compare
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.
Ship it
Introducing this method will allow some advanced use cases like requesting datafile be updated on demand.