[Feature] Introduce a task-based API and remove Result<'T, 'E> API friction
See original GitHub issueThis is an attempt to tackle #64 right now, the functions Sql.execute, Sql.executeRow, Sql.executeNonQuery etc. return data in the form of Async<Result<'SomeType, exn>>
This is fine in many cases but it can cause friction when:
- You don’t want
Resultand instead choose totry ... catchthe SQL code only on rare occasions - You are working with
task(for example in Saturn/Giraffe) and don’t want the syntax and performance overhead of converting betweenasyncandtask
I propose to fix the problems above by introducing mutually exclusive namespaces within this same nuget package that offers different return types BUT with the exact API of the Sql functions:
Npgsql.FSharpstays the same and continue to returnAsync<Result<'T, exn>>(package stays backward-compatible without breaking changes)Npgsql.FSharp.NoResultexposes API functions that returnAsync<'T>Npgsql.FSharp.Tasksexposes API functions that returnTask<'T>with the help of Ply
Yes, the downside is of course the duplication of code in each namespace but I think it is worth the effort of removing as much overhead as possible and of course we can extract the common parts in a module (the RowReader for example).
What do you think @aspnetde @TheAngryByrd @baronfel @ninofloris
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Understanding the Whys, Whats, and Whens of ValueTask
In this post, I'll cover the newer ValueTask / ValueTask<TResult> types, which were introduced to help improve asynchronous performance in ...
Read more >60+ Open APIs tried, tested and de-risked
This API provides a standardized mechanism for test case, test suite, and non-functional test model execution. This also includes allocation and provisioning of ......
Read more >What Is a REST API? Examples, Uses & Challenges
REST, which stands for Representational State Transfer, is an architectural style for distributed hypermedia systems. Learn more about REST ...
Read more >Enabling and Disabling Services
To enable and disable APIs and services you need: A Google Cloud project. To learn how to create a Google Cloud project, see...
Read more >Prioritized Task Scheduling API - MDN Web Docs
The API is promise-based and supports the ability to set and change task priorities, to delay tasks being added to the scheduler, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

As of v3.12 the library has implemented the namespace
Npgql.FSharp.Taskswhich offers the exact same API but with tasks and without Result, I haven’t gotten around to fully test it but in principle it should work 🤞 can you please give it a try and let me know how it goes? I have also updated the README docs to reflect the changes@vilinski Latest has now updated Npgsql to v5.0 and all existing tests worked without changes 😄
That’s great news! I will give it a try as soon as possible.