Тёмный

Tonic makes gRPC in Rust stupidly simple 

Dreams of Code
Подписаться 121 тыс.
Просмотров 40 тыс.
50% 1

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.
gRPC is quickly becoming my goto for implementing new services. Typically, I've used Go in order to achieve this, however recently I got to playing with Tonic, and it's made gRPC stupidly simple when it comes to Rust.
Video Links:
- Tonic: github.com/hyperium/tonic
- grpcalculator-web: github.com/dreamsofcode-io/gr...
- grpcalculator-rs: github.com/dreamsofcode-io/gr...
Become a better developer in 4 minutes: bit.ly/45C7a29 👈
Join this channel to get access to perks:
/ @dreamsofcode
Join Discord: / discord
Join Twitter: / dreamsofcode_io
00:00:00 Intro
00:00:47 Getting Started
00:02:29 Code Generation
00:03:13 gRPC Server
00:05:58 gRPCurl
00:07:09 Reflection
00:08:52 Sponsor
00:09:55 Client Code
00:11:14 Error Handling
00:12:58 State Management
00:15:09 Interceptors
00:16:49 gRPC Web

Наука

Опубликовано:

 

1 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 104   
@dreamsofcode
@dreamsofcode 3 месяца назад
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 3 месяца назад
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 3 месяца назад
Nice! Thanks for dropping this hint.
@IllllIIllllI
@IllllIIllllI 3 месяца назад
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 2 месяца назад
cargo add tonic@0.11 tokio@1 prost@0.12 --features tokio@1/full it failed without @1 in tokio feature
@AshwinKini
@AshwinKini 2 месяца назад
thank you. coming from the typescript world, I was looking for the equivalent of a "yarn add" 😬
@PopeOfDope22
@PopeOfDope22 3 месяца назад
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 3 месяца назад
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 3 месяца назад
im really happy that youre starting to differentiate urself from the fireship style vids u used to make
@thelethalmoo
@thelethalmoo 3 месяца назад
Oh man. Im in the middle of just getting going woth grpc. Great timing!
@leigh7529
@leigh7529 2 месяца назад
This is exactly what I needed today, keen to try it out!!
@recklessroges
@recklessroges 3 месяца назад
I started using Tonic 10 months ago and haven't looked back. It's excellent.
@kelvincesar_
@kelvincesar_ Месяц назад
How did you manage to create an authorization mechanism?
@bombrman1994
@bombrman1994 3 месяца назад
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 3 месяца назад
That's awesome! Well done :)
@irlshrek
@irlshrek 3 месяца назад
this looks amazing!
@IamAWESOME3980
@IamAWESOME3980 2 месяца назад
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
@shimonpertz
@shimonpertz 20 дней назад
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?
@justinclarketx
@justinclarketx 3 месяца назад
I don't know anything about Rust. But I love your videos, so I watch them all.
@site.x9448
@site.x9448 3 месяца назад
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?
@jonathanhirschbaum6754
@jonathanhirschbaum6754 3 месяца назад
Thus is our new Luke Smith, while old Luke is busy writing TempleOS but in Bash
@yakomisar
@yakomisar 3 месяца назад
Is there any ETA on video about pprof for golang?
@CielMC
@CielMC 3 месяца назад
Is nobody going to mention that monster of a wrapper for u64? Fearless ArcMutex strikes again(well in this case, fearless deadlock, lol)
@attilao
@attilao 2 месяца назад
This is beautiful. ❤
@combatLaCarie
@combatLaCarie 3 месяца назад
I want to know more about the FE version, why not envoy, how to get browser debugging.
@srinivasat5316
@srinivasat5316 3 месяца назад
can you make a video about cve-rs?
@dreamsofcode
@dreamsofcode 3 месяца назад
Ahah I can yes!
@srinivasat5316
@srinivasat5316 3 месяца назад
@@dreamsofcodeThanks
@Virens132
@Virens132 3 месяца назад
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 3 месяца назад
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 2 дня назад
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.
@ShinigamiRyto
@ShinigamiRyto 3 месяца назад
Blazingly fast 🎉😂
@Y-JA
@Y-JA 3 месяца назад
Fastest gRPC implementation of all languages according to the benchmarks I've found.
@svenyboyyt2304
@svenyboyyt2304 3 месяца назад
Could you make a video about how to make Rust bindings for Python?
@dreamsofcode
@dreamsofcode 3 месяца назад
I absolutely can!
@LactatingBadger
@LactatingBadger 3 месяца назад
@@dreamsofcode You could kill two birds with one stone here and try out the new polars extension interface
@timothyshiu2263
@timothyshiu2263 2 месяца назад
Do you have a gRPC-web tutorial?
@dreamsofcode
@dreamsofcode 2 месяца назад
I do not, but I can do one!
@timothyshiu2263
@timothyshiu2263 2 месяца назад
@@dreamsofcode that will be awesome! 👍🙏
@sid4579
@sid4579 3 месяца назад
How do you do your animations and edit videos? they look real nice
3 месяца назад
Valeu!
@dreamsofcode
@dreamsofcode 3 месяца назад
Thank you so much! I appreciate your support.
3 месяца назад
@@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/
@maroben225
@maroben225 3 месяца назад
Can you make Go gRPC ? Thank you
@bombrman1994
@bombrman1994 3 месяца назад
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 3 месяца назад
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 3 месяца назад
you were amazing I enjoy your fast content even though im total newbie in rust all together@@dreamsofcode
@IamAWESOME3980
@IamAWESOME3980 2 месяца назад
i still cant figoure out how to use tower. the lack of online tutorials, documentations, and Q&A on this is depressing
@dreamsofcode
@dreamsofcode 2 месяца назад
Tower is a little too complex imho. Especially when compared to the http stack in Go.
@IamAWESOME3980
@IamAWESOME3980 2 месяца назад
@@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
@gg.cip0t
@gg.cip0t 3 месяца назад
how can i get the font in vsCode ?
@auliobooks
@auliobooks 3 месяца назад
It‘s neovim and not VS Code
@maguilecutty
@maguilecutty 3 месяца назад
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 3 месяца назад
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 3 месяца назад
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 3 месяца назад
@@st4nn233 yeah I can see that being an issue! I think that's where JSON serialization has proto3 beat out.
@orbital1337
@orbital1337 3 месяца назад
@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.
@usercommon1
@usercommon1 3 месяца назад
cool
@bombrman1994
@bombrman1994 3 месяца назад
you showed how to install proto compiler for mac and linux only lol jokes on us windows boys
@dreamsofcode
@dreamsofcode 3 месяца назад
WSL 😅
@bombrman1994
@bombrman1994 3 месяца назад
i just did it with chocolatey@@dreamsofcode
@mctechcraft7
@mctechcraft7 3 месяца назад
Missed opportunity to use a rust wasm framework for the frontend
@dreamsofcode
@dreamsofcode 3 месяца назад
Great idea for another video though!
@combatLaCarie
@combatLaCarie 3 месяца назад
​@@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.
@NeatMemesDotCom
@NeatMemesDotCom 3 месяца назад
Don't know man... This looks like way too much trouble to avoid regular rest api
@dreamsofcode
@dreamsofcode 3 месяца назад
I wouldn't recommend replacing REST with gRPC without a good reason.
@2Sor2Fig
@2Sor2Fig 3 месяца назад
... Is a crate comparable to a framework? Asking innocently as someone who has never used Rust but knows it exists.
@dreamsofcode
@dreamsofcode 3 месяца назад
Yeah, also similar to a package as well!
@zactron1997
@zactron1997 3 месяца назад
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.
@sakhawathossen2104
@sakhawathossen2104 3 месяца назад
What IDE is that ?
@meannsen1780
@meannsen1780 Месяц назад
Neovim
@nevokrien95
@nevokrien95 3 месяца назад
The Arc seems unecessery. U dont need to refrence count it. Since its only used in the server
@shifteleven
@shifteleven 3 месяца назад
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 3 месяца назад
@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 3 месяца назад
​@@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 3 месяца назад
@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 3 месяца назад
@@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.
@metabolic_jam
@metabolic_jam 3 месяца назад
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 3 месяца назад
Grpc also provides type safety and backwards & forwards compatibility between versions of your API.
@xorlop
@xorlop 3 месяца назад
Even moderate size json I have seen 3x increase.
@talonhackbarth7652
@talonhackbarth7652 3 месяца назад
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 3 месяца назад
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 3 месяца назад
​@@lucass8119can use graphql or tRPC for type safety
@okoyl3
@okoyl3 3 месяца назад
zeromq > grpc
@InMemoryOfNeo
@InMemoryOfNeo 3 месяца назад
why?
@ovi1326
@ovi1326 3 месяца назад
isn't that apples and oranges?
Далее
When RESTful architecture isn't enough...
21:02
Просмотров 240 тыс.
🎙Пою Вживую!
2:59:56
Просмотров 1,2 млн
Binary Search Animated
7:00
Просмотров 22 тыс.
RUST Enums ARE Better
5:49
Просмотров 136 тыс.
Using docker in unusual ways
12:58
Просмотров 387 тыс.
Building micro-services in Rust using gRPC!
9:22
Просмотров 53 тыс.
Decrusting the tokio crate
3:31:48
Просмотров 48 тыс.
Индуктивность и дроссель.
1:00
Pratik Cat6 kablo soyma
0:15
Просмотров 8 млн