-
Notifications
You must be signed in to change notification settings - Fork 14
Generic file providers (Implementation of SCO-0001) #60
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
|
@finnvoor can you try this in your TOML package - does it help reduce the boilerplate? |
|
The API break is expected, we're replacing the existing JSONProvider and YAMLProvider and their reloading variants. |
|
@czechboy0 🎉 it's much easier to implement a custom file provider now (finnvoor/swift-configuration-toml#1), I just copied over |
|
Thanks for trying it out! ConfigError will remain private, you should just throw your custom TOML error instead. I'll look into whether to also make |
|
Hitting a compiler crash, filed swiftlang/swift#85280 |
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.
LGTM. Just one question
### Motivation Check out the proposal text: https://github.com/czechboy0/swift-configuration/blob/hd-sco-0001/Sources/Configuration/Documentation.docc/Proposals/SCO-0001.md ### Modifications Added the proposal, the draft implementation can be found in #60. ### Result N/A ### Test Plan N/A
Motivation
While JSON and YAML support comes built-in in Swift Configuration, it should be easier to implement additional formats in external extension packages. Right now it required copying a lot of boilerplate code (thank you @finnvoor for pointing that out).
This PR is ready to land, the API was accepted in https://forums.swift.org/t/proposal-sco-0001-generic-file-providers/82824/9
Note that this PR isn't meant to land just yet - I'll first write a proposal to solicit community feedback before moving forward.However, you're encouraged to test it out by depending on my fork's branch with this feature, to ensure it works well - if you're considering extending Swift Configuration with a new format in your own package.This PR also bumps the minimum Swift version to 6.2, since that's required by RawSpan.
Modifications
Refactors JSON and YAML providers to factor out reusable
FileProviderandReloadingFileProvidertypes that are generic over their snapshot type.This reduces the amount of code an adopter has to write to add a new format only to the parsing logic, but they get everything else related to file reading and reloading for free.
Result
An API that allows adding more file formats much more easily.
Test Plan
Adapted tests.