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

Is it possible to use dbClient non-blocking with coroutines and async controllers? #14

Open
MikhailNazarov opened this issue Dec 3, 2021 · 4 comments

Comments

@MikhailNazarov
Copy link

No description provided.

@lganzzzo
Copy link
Member

lganzzzo commented Dec 4, 2021

Hello @MikhailNazarov ,

The short answer is - this API is not implemented yet. At the moment we encourage to use simple API in case you need ORM.

However, it is possible:
You need a thread pool...

  • You post DB request to thread pool from Coroutine (coroutine waits asynchronously without blocking the processing loop).
  • Once request is ready - result is returned back to Coroutine.

This is the way it will be implemented in the future (with some convenience APIs).

@MikhailNazarov
Copy link
Author

Thank you, you have a great framework. With this feature will be the best!

@MikhailNazarov
Copy link
Author

Does oatpp have a thread pool implementation?
I found the Pool class - use it for a thread pool?

Do I understand correctly that for this task I need to use the IOEventWorker?

@lganzzzo
Copy link
Member

lganzzzo commented Dec 5, 2021

At the moment oatpp doesn't have thread-pool implementation.

I found the Pool class - use it for a thread pool?

That pool is a kind of resource pool - it's used for ConnectionPool in ORM and Network. It also can be used for any resource.
But it's not suitable for threads - just because of the performance - you don't want to start-stop new threads in the thread pool.

Do I understand correctly that for this task I need to use the IOEventWorker?

You don't have to use it directly. Oatpp does that for you.

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

2 participants