Skip to content
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

Refactor configuration struct and add /config endpoint. #132

Merged
merged 8 commits into from Jan 28, 2020

Conversation

mikecdavis
Copy link
Contributor

Summary

  • Move Author, Name and Version to root config
  • Move SDKKeys and Processor to root config
  • Add uptime to /info because it seamed like a good idea
  • Add admin /config route to support operations and validate config
  • Updates README.md and config.yaml

Exposing "optly" in the configs was gross. Moving items to the root of the application config felt more appropriate in some cases as Agent is optimizely. I also wanted to expose the configuration in the routes as this is a handy endpoint when you want to confirm that certain configs are loaded etc.

@codecov
Copy link

codecov bot commented Jan 24, 2020

Codecov Report

Merging #132 into master will increase coverage by 0.44%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #132      +/-   ##
==========================================
+ Coverage   76.18%   76.62%   +0.44%     
==========================================
  Files          23       24       +1     
  Lines         865      890      +25     
==========================================
+ Hits          659      682      +23     
- Misses        170      172       +2     
  Partials       36       36              
Impacted Files Coverage Δ
pkg/routers/api.go 81.81% <0.00%> (-0.54%) ⬇️
pkg/middleware/utils.go 100.00% <0.00%> (ø) ⬆️
pkg/handlers/user_overrides.go 72.97% <0.00%> (ø)
pkg/middleware/cached.go 87.65% <0.00%> (+0.31%) ⬆️
pkg/handlers/user.go 75.53% <0.00%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0825a48...d791ddf. Read the comment docs.

sg.GoListenAndServe("api", conf.API.Port, routers.NewDefaultAPIRouter(optlyCache, conf.API, agentMetricsRegistry))
sg.GoListenAndServe("webhook", conf.Webhook.Port, routers.NewWebhookRouter(optlyCache, conf.Webhook))
sg.GoListenAndServe("admin", conf.Admin.Port, routers.NewAdminRouter(conf.Admin)) // Admin should be added last.
sg.GoListenAndServe("admin", conf.Admin.Port, routers.NewAdminRouter(*conf)) // Admin should be added last.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should NewAdminRouter accept a pointer type, instead of dereferencing it here?

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 was going back and forth on this. I wanted to be consistent with all of the the other constructors which are not using a pointer.

config/config.go Outdated
Log LogConfig `yaml:"log" json:"log"`
Processor ProcessorConfig `yaml:"processor" json:"processor"`
Server ServerConfig `yaml:"server" json:"server"`
Webhook WebhookConfig `yaml:"webhook" json:"webhook"`
}

// OptlyConfig holds the set of SDK keys to bootstrap during initialization
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to update this comment

config/config.go Outdated
BatchSize int `yaml:"batchSize" default:"10"`
QueueSize int `yaml:"queueSize" default:"1000"`
FlushInterval time.Duration `yaml:"flushInterval" default:"30s"`
BatchSize int `yaml:"batchSize" json:"batchSize" default:"10"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: any lint or test we can set up to ensure both yaml and json remappings on everything?

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 can see if these two can be consolidated.

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 couldn't find one, but since yaml is only used for unmarshaling then we don't technically need to map the field names. We do however need the json field mappings to yield the desired casing in the /config endpoint so I'll remove the yaml to avoid any potential discrepancies.

@@ -38,12 +38,12 @@ type OptlyCache struct {
optlyMap cmap.ConcurrentMap
ctx context.Context
wg sync.WaitGroup
conf config.OptlyConfig
conf config.ProcessorConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this field to processorConf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no objections

@mikecdavis mikecdavis merged commit 7150ab1 into master Jan 28, 2020
@mikecdavis mikecdavis deleted the mikecdavis/OASIS-5904-update-config-docs branch January 28, 2020 20:31
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.

None yet

2 participants