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

Can we use async await #342

Closed
Didza opened this issue Mar 6, 2023 · 3 comments
Closed

Can we use async await #342

Didza opened this issue Mar 6, 2023 · 3 comments

Comments

@Didza
Copy link

Didza commented Mar 6, 2023

Amazing work, Can we use async await with this for external calls e.g the database? If not why not, if we can what are the reasons for not adding this? Thank you!!!

@Didza Didza changed the title can we use async await Can we use async await Mar 6, 2023
@suspiciousRaccoon
Copy link

This repo uses fastapi. Might be what you're looking for.

@hjwp
Copy link
Contributor

hjwp commented Jan 8, 2024

async/await can actually be a really nice way to separate out code with side-effects from your domain model, which should be side-effect free.

in terms of the patterns in the book, it would tend to mean that anything involving a repostiory, and anything involving the UoW, becomes async. that's unfortunate because, if you want to test everything at the service layer, all your tests become async tests, which are a bit slow. so either you accept that as a cost/compromise, or you do more non-async/unit testing at the lower/domain layer. or maybe there's a clever way to avoid async in the service layer / repository / uow! that last is an open question, for me.

another way of thinking about it is that async can make it really visible, in code, as to how well you're doing with the "functional core imperative shell" pattern. so i think it can be really good!

@hjwp hjwp closed this as completed Jan 8, 2024
@Didza
Copy link
Author

Didza commented Jan 9, 2024

Blocking calls to external resources create an overhead where the thread is blocked from serving other requests, async/await can lead to performance improvements in these scenarios. It allows for non-blocking I/O operations, which is particularly beneficial in web servers and applications dealing with high I/O workloads.

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

No branches or pull requests

3 participants