Tonic makes gRPC in Rust stupidly simple

  Рет қаралды 54,227

Dreams of Code

Dreams of Code

Күн бұрын

Пікірлер: 115
@dreamsofcode
@dreamsofcode 10 ай бұрын
To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/DreamsofCode/ . The first 200 of you will get 20% off Brilliant’s annual premium subscription.
@mattshnoop
@mattshnoop 10 ай бұрын
1:00 Small piece of info, but Cargo now has support for the `cargo add` command, so you can add your dependencies without needing to edit the file manually 🙂 For example: cargo add tonic@0.11 tokio@1 prost@0.12 --features tokio/full cargo add --build tonic-build@0.11
@dreamsofcode
@dreamsofcode 10 ай бұрын
Nice! Thanks for dropping this hint.
@IllllIIllllI
@IllllIIllllI 10 ай бұрын
I wish rust-analyzer picked up on dependencies added this way, but you still have to manually save the cargo.toml file for it to notice
@pangleopang1550
@pangleopang1550 10 ай бұрын
cargo add tonic@0.11 tokio@1 prost@0.12 --features tokio@1/full it failed without @1 in tokio feature
@AshwinKini
@AshwinKini 9 ай бұрын
thank you. coming from the typescript world, I was looking for the equivalent of a "yarn add" 😬
@nathanphan3042
@nathanphan3042 2 ай бұрын
nice! I know new tips
@PopeOfDope22
@PopeOfDope22 10 ай бұрын
The quality of your content is skyrocketing. The information flow couple with the animation is clear, concise and straigth to the point. Well done and thank you :)
@dreamsofcode
@dreamsofcode 10 ай бұрын
Thank you! I appreciate that a lot. I'm also glad you're enjoying it. I'm v excited to see how much I can grow this next year as well. :)
@ali.005
@ali.005 10 ай бұрын
im really happy that youre starting to differentiate urself from the fireship style vids u used to make
@TheHellishFrog
@TheHellishFrog 6 ай бұрын
Excellent tutorial - many thanks to the creator! However - at the beginning of the June 2024 Tonic was updated to use new version of axum, new version of hyper, and new tower crate. This great tutorial is deserved to be upgraded too!
@recklessroges
@recklessroges 10 ай бұрын
I started using Tonic 10 months ago and haven't looked back. It's excellent.
@kelvincesar_
@kelvincesar_ 9 ай бұрын
How did you manage to create an authorization mechanism?
@thelethalmoo
@thelethalmoo 10 ай бұрын
Oh man. Im in the middle of just getting going woth grpc. Great timing!
@smoov8345
@smoov8345 6 ай бұрын
Great job! My first dabbling in Rust gRPC worked thanks to your video.
@IamAWESOME3980
@IamAWESOME3980 9 ай бұрын
thanks for the tutorial, i was reading so many articles on the web trying to figure how the hell to get reflections to work lol, none helped
@bombrman1994
@bombrman1994 10 ай бұрын
very nice I have continued implementing other mathematical operations, this was very nice thing to learn. I am just a newbie in rust
@dreamsofcode
@dreamsofcode 10 ай бұрын
That's awesome! Well done :)
@leigh7529
@leigh7529 9 ай бұрын
This is exactly what I needed today, keen to try it out!!
@srinivasat5316
@srinivasat5316 10 ай бұрын
can you make a video about cve-rs?
@dreamsofcode
@dreamsofcode 10 ай бұрын
Ahah I can yes!
@srinivasat5316
@srinivasat5316 10 ай бұрын
@@dreamsofcodeThanks
10 ай бұрын
Valeu!
@dreamsofcode
@dreamsofcode 10 ай бұрын
Thank you so much! I appreciate your support.
10 ай бұрын
@@dreamsofcodeI did a little POC using gRPC and lost it 2 days ago. Your video will help me to re do it. Thank you o/
@justinclarketx
@justinclarketx 10 ай бұрын
I don't know anything about Rust. But I love your videos, so I watch them all.
@Virens132
@Virens132 10 ай бұрын
Tonic doesn't do a particularly good job at abstracting away the details of reflection. I wouldn't describe having to think about "file descriptor sets" as stupidly simple.
@dreamsofcode
@dreamsofcode 10 ай бұрын
Yeah I'm inclined to agree, it's certainly one of the weaker parts of tonic. I'd love to see some improvements made here!
@artxiom
@artxiom 7 ай бұрын
I would argue it's still quite simple: it's an extremely powerful (and complex) feature and all you have to do is add a few lines of code. But yes, ergonomics could be improved and it would make it even better if the file descriptors could be generated together with the rest. Adding tonic-reflection as a feature to tonic itself would probably solve this.
@antifa_communist
@antifa_communist 10 ай бұрын
Could you make a video about how to make Rust bindings for Python?
@dreamsofcode
@dreamsofcode 10 ай бұрын
I absolutely can!
@LactatingBadger
@LactatingBadger 10 ай бұрын
@@dreamsofcode You could kill two birds with one stone here and try out the new polars extension interface
@jonathanhirschbaum6754
@jonathanhirschbaum6754 10 ай бұрын
Thus is our new Luke Smith, while old Luke is busy writing TempleOS but in Bash
@EhdrianEh
@EhdrianEh 7 ай бұрын
Bookmarked! Thanks!
@shimonpertz
@shimonpertz 7 ай бұрын
Great video, Thanks for the Efforts! I have a question please. What if you have a Desktop app built with Rust and Tauri on some computer and you gRPC in a server. How to enable the Desktop to connect to the remote gRPC that is hosted somewhere in the cloud?
@ФёдорМостовой-й9п
@ФёдорМостовой-й9п 4 ай бұрын
What about testing server, client and their communication (e2e)?
@dreamsofcode
@dreamsofcode 4 ай бұрын
The same as you would with http!
@nathanphan3042
@nathanphan3042 2 ай бұрын
what's your theme of vim editor, so delightful
@yakomisar
@yakomisar 10 ай бұрын
Is there any ETA on video about pprof for golang?
@combatLaCarie
@combatLaCarie 10 ай бұрын
I want to know more about the FE version, why not envoy, how to get browser debugging.
@site.x9448
@site.x9448 10 ай бұрын
I'm a developer who started learning editing as well. Your videos are awesome! Please, can you share what software do you use to create such incredible videos & animations?
@CielMC
@CielMC 10 ай бұрын
Is nobody going to mention that monster of a wrapper for u64? Fearless ArcMutex strikes again(well in this case, fearless deadlock, lol)
@ricksanchez207
@ricksanchez207 2 ай бұрын
wait tonic for rust? gin for go?
@dangelgeek
@dangelgeek Ай бұрын
Thank you very much!!!
@bombrman1994
@bombrman1994 10 ай бұрын
btw, you have explained all nicely, but at 11 minutes you are executing the --bin client without executing --server to the viewer and that can be missleading since -bin server needs to be up priot to the client execution. Just saying it in case there are people stuck at that step and they did not think of this at all since they are noobs just like myself
@dreamsofcode
@dreamsofcode 10 ай бұрын
Sorry about that! Thank you for letting me know (and sharing the comment). I'll try to be a bit more careful with my cuts in the future.
@bombrman1994
@bombrman1994 10 ай бұрын
you were amazing I enjoy your fast content even though im total newbie in rust all together@@dreamsofcode
@ShinigamiRyto
@ShinigamiRyto 10 ай бұрын
Blazingly fast 🎉😂
@Y-JA
@Y-JA 10 ай бұрын
Fastest gRPC implementation of all languages according to the benchmarks I've found.
@irlshrek
@irlshrek 10 ай бұрын
this looks amazing!
@IamAWESOME3980
@IamAWESOME3980 9 ай бұрын
i still cant figoure out how to use tower. the lack of online tutorials, documentations, and Q&A on this is depressing
@dreamsofcode
@dreamsofcode 9 ай бұрын
Tower is a little too complex imho. Especially when compared to the http stack in Go.
@IamAWESOME3980
@IamAWESOME3980 9 ай бұрын
@@dreamsofcode we need more rust tutorials. this is a must for any language that seek mainstream adoption. i am a front-end software engineer trying to pivot to the backend. i have to say rust has a serious learning curve. i am looking forward to your next video on how to create a middleware with tower for tonic
@maroben225
@maroben225 10 ай бұрын
Can you make Go gRPC ? Thank you
@maguilecutty
@maguilecutty 10 ай бұрын
Be aware. It is waaaaay more of a pain in the arse when scaling this to an actual production use case. Everything that took 5 seconds in the video will take u 5 days irl!
@dreamsofcode
@dreamsofcode 10 ай бұрын
What issues did you run into? I've got a couple of projects ATM so would be good to know for when I encounter them!
@st4nn233
@st4nn233 10 ай бұрын
My take here would be options... I know it's not Rust's fault, but the move to remove the required statement between proto2 and proto3 was a mistake IMHO, this is particularly bad in Rust as there is no cheeky way around options. Deeply nested messages create an "if let" / "match" hell very quickly.
@dreamsofcode
@dreamsofcode 10 ай бұрын
@@st4nn233 yeah I can see that being an issue! I think that's where JSON serialization has proto3 beat out.
@orbital1337
@orbital1337 10 ай бұрын
@33 Well yeah, the protobuf type system just sucks. It's evolved over the years to suit the needs of Google who care more about shaving off some bytes than the painful developer experience.
@headlibrarian1996
@headlibrarian1996 6 ай бұрын
@@dreamsofcode Flatbuffers would be even better but I don't know if the Rust edition of GRPC supports them. The C++ edition supposedly does though.
@attilao
@attilao 9 ай бұрын
This is beautiful. ❤
@markedosa
@markedosa 7 ай бұрын
This is fantastic
@gg.cip0t
@gg.cip0t 10 ай бұрын
how can i get the font in vsCode ?
@NeatMemesDotCom
@NeatMemesDotCom 10 ай бұрын
Don't know man... This looks like way too much trouble to avoid regular rest api
@dreamsofcode
@dreamsofcode 10 ай бұрын
I wouldn't recommend replacing REST with gRPC without a good reason.
@nevokrien95
@nevokrien95 10 ай бұрын
The Arc seems unecessery. U dont need to refrence count it. Since its only used in the server
@shifteleven
@shifteleven 10 ай бұрын
I’m not a compiler, but I think it is needed since the counter is shared in the asynchronous trait context. And while it’s used in the server, I assume the server is multithreaded and two threads could try to access the value at the same time. The arc is then ensures proper memory access and updating
@nevokrien95
@nevokrien95 10 ай бұрын
@shifteleven it should be a mutex but I don't get why the reference counter. I come from a more c background so it could just be "rust forces u to do bloaty code" but I m giving rust more credit.
@Tarekconqueso
@Tarekconqueso 10 ай бұрын
​@@nevokrien95 it's executed inside a tokio runtime, which is async. One of the drawbacks of async rust is once it's async, you have to use thread safe mechanics such as Arcs, even if the executor is mono threaded. I'm no expert but I believe the code would not compile with a state not wrapped in an Arc.
@juanfrancisconavarrorodrig567
@juanfrancisconavarrorodrig567 10 ай бұрын
@nevokrien95 the reason for having an rc wrapping an object, is to free the associated resource as soon as we stop referencing it in our program. This is not just boilerplate: its more than what C does. In C you would be expected to manually keep track of ownership of an object in order to free its memory (and release its resources)
@irlshrek
@irlshrek 10 ай бұрын
@@nevokrien95 you could use RwLock if the thing youre working with is going to be read from much more than written to. Youre right though that it could be a Mutex. the difference is that with RwLock you dont have to wait for another thread (or RPC call, as it were) to release the lock if its just reading, whereas with a Mutex, you would. The draw back though is that if you have a BUNCH of threads reading the RwLock, you may struggle to get a lock to write to it. Also RwLock has a bit more developer overhead.
@sakhawathossen2104
@sakhawathossen2104 10 ай бұрын
What IDE is that ?
@nocontent-s6g
@nocontent-s6g 8 ай бұрын
Neovim
@2Sor2Fig
@2Sor2Fig 10 ай бұрын
... Is a crate comparable to a framework? Asking innocently as someone who has never used Rust but knows it exists.
@dreamsofcode
@dreamsofcode 10 ай бұрын
Yeah, also similar to a package as well!
@zactron1997
@zactron1997 10 ай бұрын
Yeah a crate is a collection of code, similar to a module, package, or library in some other languages. In JavaScript you use npm to install a module. In Python you use pip to install a package. In Rust you use cargo to install a crate. I believe Rust chose this word specifically to avoid confusion with other languages, since while a package, module, and crate are all conceptually the same thing (a bundle of code), they do have some slight differences in their rules.
@mctechcraft7
@mctechcraft7 10 ай бұрын
Missed opportunity to use a rust wasm framework for the frontend
@dreamsofcode
@dreamsofcode 10 ай бұрын
Great idea for another video though!
@combatLaCarie
@combatLaCarie 10 ай бұрын
​@@dreamsofcode I'm happy it isn't. Professionally grpc is something I can see as viable, but I can't advocate for a rust wasm framework at this time.
@bombrman1994
@bombrman1994 10 ай бұрын
you showed how to install proto compiler for mac and linux only lol jokes on us windows boys
@dreamsofcode
@dreamsofcode 10 ай бұрын
WSL 😅
@bombrman1994
@bombrman1994 10 ай бұрын
i just did it with chocolatey@@dreamsofcode
@babichjacob
@babichjacob 7 ай бұрын
It's easy with scoop! `scoop bucket add extras` then `scoop install protobuf`
@atascon007
@atascon007 5 ай бұрын
0.12 just dropped... gtg again
@usercommon1
@usercommon1 10 ай бұрын
cool
@energy-tunes
@energy-tunes 5 ай бұрын
XD
@metabolic_jam
@metabolic_jam 10 ай бұрын
Grpc isn’t needed for most cases. Unless you’re passing huge blobs of json and the cost of serialization is introducing latency 😂
@MaksKolman
@MaksKolman 10 ай бұрын
Grpc also provides type safety and backwards & forwards compatibility between versions of your API.
@xorlop
@xorlop 10 ай бұрын
Even moderate size json I have seen 3x increase.
@talonhackbarth7652
@talonhackbarth7652 10 ай бұрын
It really depends on what you're doing. If you have any API that you need clients for across multiple languages, it is a huge help because it's language agnostic. It's also been very useful for me because at work we use it to stream data extremely quickly which is important for our use case. That said, if your project does not need to scale multiple languages or the speed of rest APIs works for your use case, it is faster to get rest set up. I will say though, as a small team, grpc saves a lot of time we would have had to spend documenting our API if we were using rest, whereas proto definitions are by nature almost self documenting.
@lucass8119
@lucass8119 10 ай бұрын
Yes but JSON is weakly typed, so you need something like OpenAPI to actually make it usable. The complexity is quite high, because JSON is broken in a fundamental way and therefore requires massive amounts of tooling to make somewhat decent.
@killerdroid99
@killerdroid99 10 ай бұрын
​@@lucass8119can use graphql or tRPC for type safety
@okoyl3
@okoyl3 10 ай бұрын
zeromq > grpc
@InMemoryOfNeo
@InMemoryOfNeo 10 ай бұрын
why?
@ovi1326
@ovi1326 10 ай бұрын
isn't that apples and oranges?
@sid4579
@sid4579 10 ай бұрын
How do you do your animations and edit videos? they look real nice
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 287 М.
Setting up a production ready VPS is a lot easier than I thought.
29:50
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
You Should Really Know These Traits in Rust
18:36
Oliver Jumpertz
Рет қаралды 17 М.
10 things I learnt in 2024 to increase my developer productivity.
18:46
RUST Enums ARE Better
5:49
ThePrimeagen
Рет қаралды 147 М.
Rust Interior Mutability - Sneaking By The Borrow Checker
16:02
Code to the Moon
Рет қаралды 75 М.
Web Developers Are Disconnected
21:36
ThePrimeTime
Рет қаралды 228 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level
Рет қаралды 365 М.
Now I Know Why Most People Don’t Use gRPC
19:11
ArjanCodes
Рет қаралды 61 М.
Why You Shouldn’t Build Your Next App in Rust
9:18
warpdotdev
Рет қаралды 104 М.
Building micro-services in Rust using gRPC!
9:22
Let's Get Rusty
Рет қаралды 57 М.
docker stack is my new favorite way to deploy to a VPS
27:47
Dreams of Code
Рет қаралды 136 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН