feat(Async): Add IAsyncConfigurationReader + ParseAsync overload#317
Open
dimension-zero wants to merge 4 commits into
Open
feat(Async): Add IAsyncConfigurationReader + ParseAsync overload#317dimension-zero wants to merge 4 commits into
dimension-zero wants to merge 4 commits into
Conversation
* ConfigReaders.fs:
- New IAsyncConfigurationReader interface mirroring
IConfigurationReader with GetValueAsync : string -> Task<string>.
- ConfigurationReader.AsAsync(reader) wraps any sync reader as async
via Task.FromResult — useful when callers want to pass existing
readers through the async parse path.
- ConfigurationReader.FromAsyncFunction(asyncFn, ?name) builds a
reader from an F# Async<string option>.
* ArgumentParser.fs new ParseAsync overload: fetches every top-level
AppSettings key the schema references via the async reader, awaits
each, then runs the regular sync Parse against a Dictionary-backed
snapshot. One round-trip per declared key; below ParseAsync, the
parser stays purely synchronous so existing tests and behaviour are
unaffected.
Hosts that previously had to block on an async config source can now
use ParseAsync directly:
do! parser.ParseAsync(configurationReader = remoteAsync) |> Async.AwaitTask
5 new tests: * ConfigurationReader.AsAsync wraps a sync reader; the wrapped Task resolves to the same value and preserves Name. * ParseAsync via AsAsync(sync reader) yields the same parse results as the original sync Parse against that reader. * ParseAsync pre-fetches each schema-declared AppSettings key exactly once (Interlocked-counted via a custom IAsyncConfigurationReader), guarding the implementation's contract. * ConfigurationReader.FromAsyncFunction adapts an F# Async<string option> to IAsyncConfigurationReader and parses round-trip. * ParseAsync forwards ignoreUnrecognized to the underlying sync Parse (CLI tokens not in the schema land in UnrecognizedCliParams). Net suite size on this branch: 112 -> 117.
risk: LOW (score: 0.0, no analysable symbols)
Collaborator
|
@bartelink do you have some bandwidth to review these PRs? |
Member
|
lol, did T-Gro mention I'm atting him too much and need to take a break :D The PRs thankfully look pretty reviewable but ngl I was hoping they'd magically get merged by 'someone'! But yes, I do have space atm so I'll chip away at them |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(Async): Add IAsyncConfigurationReader + ParseAsync overload
IConfigurationReader with GetValueAsync : string -> Task.
via Task.FromResult — useful when callers want to pass existing
readers through the async parse path.
reader from an F# Async.
AppSettings key the schema references via the async reader, awaits
each, then runs the regular sync Parse against a Dictionary-backed
snapshot. One round-trip per declared key; below ParseAsync, the
parser stays purely synchronous so existing tests and behaviour are
unaffected.
Hosts that previously had to block on an async config source can now
use ParseAsync directly:
do! parser.ParseAsync(configurationReader = remoteAsync) |> Async.AwaitTask
test(ParseAsync): Coverage for IAsyncConfigurationReader + ParseAsync
5 new tests:
resolves to the same value and preserves Name.
the original sync Parse against that reader.
once (Interlocked-counted via a custom IAsyncConfigurationReader),
guarding the implementation's contract.
to IAsyncConfigurationReader and parses round-trip.
(CLI tokens not in the schema land in UnrecognizedCliParams).
Net suite size on this branch: 112 -> 117.