Repository navigation
fix(conf): unify datasource constructor return types - #1265
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1265 +/- ##
==========================================
+ Coverage 47.09% 51.20% +4.11%
==========================================
Files 236 236
Lines 10921 9200 -1721
==========================================
- Hits 5143 4711 -432
+ Misses 5326 4489 -837
+ Partials 452 0 -452 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
CI note: the golangci-lint workflow currently reports pre-existing unused symbols in |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are small, consistent with the stated goal, and preserve behavior while aligning constructor return types to the existing conf.DataSource interface.
Pull request overview
This PR standardizes the public constructor API across pkg/conf/datasource implementations by having the file- and HTTP-backed NewDataSource constructors return the public conf.DataSource interface (matching the Apollo and etcdv3 implementations), keeping callers decoupled from concrete datasource types.
Changes:
- Updated
pkg/conf/datasource/file.NewDataSourceto returnconf.DataSource. - Updated
pkg/conf/datasource/http.NewDataSourceto returnconf.DataSource. - Refined Go doc comments on both constructors to describe the backing implementation (file/HTTP).
File summaries
| File | Description |
|---|---|
| pkg/conf/datasource/http/yasee.go | Returns conf.DataSource from the HTTP datasource constructor and updates its exported doc comment. |
| pkg/conf/datasource/file/file.go | Returns conf.DataSource from the file datasource constructor and updates its exported doc comment. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Describe what this PR does / why we need it
The file and HTTP configuration datasource constructors return unexported concrete types, while the Apollo and etcdv3 constructors return the public
conf.DataSourceinterface. This PR makes allpkg/conf/datasourceNewDataSourceconstructors expose the same public interface, keeping callers decoupled from implementation details.Does this pull request fix one issue?
Fixes #1264
Describe how you did it
pkg/conf/datasource/file.NewDataSourceto returnconf.DataSource.pkg/conf/datasource/http.NewDataSourceto returnconf.DataSource.Describe how to verify it
go test -race ./pkg/conf/...go vet ./pkg/conf/...go build ./...golangci-lint v1.62.2 run --new-from-rev=origin/mastergit diff --checkThe focused checks pass locally. A full
go test ./...was also attempted, but this machine does not have the repository's etcd, Redis, RocketMQ, and MySQL services (or Docker) running; the resulting failures are in unrelated integration tests.Special notes for reviews
The concrete return types are intentionally hidden because the public contract is
conf.DataSource; the repository's existing call sites already consume the interface. The PR is based on the currentmasterbranch.