Unfortunately, this code doesn't work with more recent versions of the tonic and postgres libraries.
You will hit the error:
thread 'tokio-runtime-worker' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.'
Because postgres driver executes runtime.block_on inside the block_on coming from #[tokio:main]
Thanks for letting the comment to help others. I will upgrade it later if I have to use Rust with gRPC again. Until then, it will be better to read this post only to learn the workflow to use gRPC with Rust and Tonic.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Unfortunately, this code doesn't work with more recent versions of the tonic and postgres libraries.
You will hit the error:
Because postgres driver executes
runtime.block_on
inside theblock_on
coming from#[tokio:main]
Thanks for letting the comment to help others. I will upgrade it later if I have to use Rust with gRPC again. Until then, it will be better to read this post only to learn the workflow to use gRPC with Rust and Tonic.