When RESTful architecture isn't enough...

When RESTful architecture isn't enough...

Dreams of Code

7 месяцев назад

243,197 Просмотров

REST has always been my preferred interface architecture, but it doesn't always fit every use case. Some times, it's better to use an RPC interface instead.

gRPC has brought with it some awesome features and tooling, and is often a better solution for RPC.

This video was sponsored by Acorn Labs. You can deploy your own version of the calculator API using the URL below.

https://acorn.io/run/docker.io/dreamsofcode/grpcalculator:acorn?ref=dreamsofcode

Video Links:
Github Repository: https://github.com/dreamsofcode-io/grpc
Acorn: https://acorn.io
grpcui: https://github.com/fullstorydev/grpcui
grpcurl: https://github.com/fullstorydev/grpcurl

Become a better developer in 4 minutes: https://bit.ly/45C7a29 👈

Join this channel to get access to perks:
https://www.youtube.com/channel/UCWQaM7SpSECp9FELz-cHzuQ/join

Join Discord: https://discord.com/invite/eMjRTvscyt
Join Twitter: https://twitter.com/dreamsofcode_io

00:00 Intro
00:27 What is RPC
02:32 gRPC & Protocol Buffers
05:46 Building a gRPC server
12:54 Error handling
15:47 Repeated
17:07 Building a gRPC Client
18:59 One last thing

Тэги:

#grpc #gRPCui #grpcurl #api #rest #resftul #architecture #software #development #coding
Ссылки и html тэги не поддерживаются


Комментарии:

@greed7513
@greed7513 - 28.11.2023 08:32

please do not steer development into grpc, I am not smart enough

Ответить
@ThinhNguyen-cq8jp
@ThinhNguyen-cq8jp - 26.11.2023 22:11

So basiclly GraphQL, omg

Ответить
@jms2182
@jms2182 - 26.11.2023 22:02

Please... Python

Ответить
@ahmadmiqdaadabdulaziz6163
@ahmadmiqdaadabdulaziz6163 - 26.11.2023 15:15

can you make a demo using nodejs ... hehe

Ответить
@onee1594
@onee1594 - 26.11.2023 12:27

"much more secure than running locally" that's where you quit watching the video

Ответить
@binodtharu7016
@binodtharu7016 - 25.11.2023 16:45

u got my sub bro ❤

Ответить
@renegade5942
@renegade5942 - 24.11.2023 23:32

The browser does not support gRPC which is a bummer

Ответить
@CDeveloper-yr2oe
@CDeveloper-yr2oe - 24.11.2023 17:51

Please do gRPC video using C#

Ответить
@if7dmitrij191
@if7dmitrij191 - 23.11.2023 14:58

Bruh, I realy made my APIs like this and had no idea it's called RPC 💀

Ответить
@animanaut
@animanaut - 23.11.2023 13:51

looks like somebody picked up the dropped ... SOAP 🤣
bad joke, i know, but this video triggered some dejavu's for me
good video, as always. thx

Ответить
@RiversJ
@RiversJ - 22.11.2023 23:02

Ain't nobody sane writing their OpenAPI docs themselves, attribute configuration for example in C# will produce the correct results automatically and you can automate the endpoint mapping.

Ответить
@stefanusayudha1853
@stefanusayudha1853 - 22.11.2023 19:31

can protobuf define form rule?
like input A cannot be greater than 9.

Ответить
@JBBell
@JBBell - 22.11.2023 17:54

This really seems like the difference between OOP and functional programming to my admittedly pretty naive eyes. I can see where some blending is likely over time.

Ответить
@jpsolares
@jpsolares - 22.11.2023 01:29

GRPC on php please :D

Ответить
@PieJee1
@PieJee1 - 21.11.2023 23:22

How do you make updates to an existing grpc? Wouldnt that require update frontend and backend at the same time so they follow the same contract again?

Ответить
@gamerwatche
@gamerwatche - 21.11.2023 23:00

How can i design my terminal to look as good as yours?

Ответить
@cheesepie4ever
@cheesepie4ever - 21.11.2023 11:51

Hey your video was very well produced I like the way you explained it!

Ответить
@archmad
@archmad - 21.11.2023 08:06

if you want the flexibility of rest and graphql, forget grpc. it's not meant to be flexible. Few things to consider: date/time, envoy, and type generators for your web client, you just have to accept the oddity, not disadvantages, just different.

Ответить
@phaberest1163
@phaberest1163 - 21.11.2023 01:03

Hey @dreamsofcode, would you please compare gRPC to GraphQL as well?

Ответить
@adhirajbhattacharya8574
@adhirajbhattacharya8574 - 20.11.2023 08:37

Can somebody explain on what is meant by the sentence native web support? How is it there for REST but not gRPC? Any example if possible.

Ответить
@leomotta5376
@leomotta5376 - 20.11.2023 04:56

I wish this video was with nodejs

Ответить
@epickh64
@epickh64 - 19.11.2023 23:01

Wait... The sponsor is "Acorn"? I know that they are a different company, but the name is similar to that of the company which invented the ARM architecture, Acorn Computers Ltd. . Just reminded me of that.
Nice video, anyways; the animations are great.

Ответить
@VMiXEZ
@VMiXEZ - 19.11.2023 18:17

gRPC is really good, I love using it. Only downside is that it needs envoy to support web client.

Ответить
@GreatWalker
@GreatWalker - 19.11.2023 14:20

I sometimes find gRPC extremely slow, even when doing the simplest of RPCs

Ответить
@alejandrombc
@alejandrombc - 19.11.2023 06:38

So the Error type does not appear in the contract with the client? 🤔.

Also, is there a way to include more “custom” validation in our contract?, for example in openapi you can put min/max limits, regex and other stuff? (or at least include a message to indicate something)

Ответить
@goisenate
@goisenate - 19.11.2023 02:07

So we're back 20+ years to SOAP with WSDL and XSD.
This is not a bad thing per se but let's agree this is not an innovation.
Yes, ProtoBuf is pretty efficient compared to the clunky XML messages in SOAP.
And I'm excited about the Subscription capabilities in gRPC. Your videos are well-done and informative, so I'd be grateful for a video on Pub/Sub with gRPC.

On the other hand, in gRPC, we lose the whole hypermedia concept of REST/HATEOAS/HAL.
In well-done RESTful APIs you don't care about IDs and what endpoint to call because the resourse you GET contains hypermedia links with the exact endpoint to call (including the ID). To me, that was a truly remarkable shift in mindset when designing APIs.

In closing, I appreciate this video. It illustates well that RESTful thinking does not fit to all problems, building a calculator being one of them.
Thanks!

Ответить
@clamhammer2463
@clamhammer2463 - 18.11.2023 22:36

lol... "first we need to install a couple of tools..." x17

No thanks.

Ответить
@delanyo
@delanyo - 18.11.2023 18:26

Great video of grpc. Would love to see an example in nodejs

Ответить
@thebestofthequest7486
@thebestofthequest7486 - 18.11.2023 14:39

Could you do a video about gRPC in rust?

Ответить
@dn5426
@dn5426 - 18.11.2023 11:20

gRPC is great for internal server <-> server but I think it falls short everywhere else.

Ответить
@Armetron
@Armetron - 18.11.2023 04:03

When I worked at Google we had to used gRPC for our apis, the language we used was Java for a microservice

Ответить
@draconicproductionsinactiv5717
@draconicproductionsinactiv5717 - 18.11.2023 01:50

what terminal do you use?

Ответить
@jaredconnor7156
@jaredconnor7156 - 17.11.2023 23:39

Hey, I know you have said before that you were going to show how you make your animations, I'm really impressed with them! In terms of tooling, you've said before that you use ffmpeg for terminal recording. What do you use for the animations or editing?

Ответить
@nikjs
@nikjs - 17.11.2023 19:44

please do this in Python and show

Ответить
@Omnifarious0
@Omnifarious0 - 17.11.2023 17:02

There is a major difference between RESTful and RPC-based APIs. By their very nature, every single RESTful operation is atomic. And a good portion of them are guaranteed to be idempotent. This is not at all true with RPC-based APIs.

Additionally, it's very tempting to model an RPC based API as a function call (after all, the word "procedure" is in the name). This is a terrible idea.

Function calls, by their nature, have no built-in latency. The function itself may take some time. But the call takes hardly any time. This is not at all true for RPC calls. Every single call comes with non-trivial (usually at least microseconds, and often milliseconds) latency.

Additionally, function calls are 'reliable'. Oh, your program my die. The function call may not be able to accomplish its task and report a failure. But, your function call isn't going to fail in flight where it seems like maybe it failed, but the call is actually running. This isn't true of an RPC 'call'. And the lack of guarantee of idempotency makes that a huge problem.

So, once you move to an RPC model, the problems you have to solve just became hugely more complex. And the care you have to exercise in crafting your interface is extraordinary. Do not use an RPC API unless you absolutely have to. And when you do, please design it as if you were designing a protocol, not a function call interface. Because that's what you're doing.

It should NOT be called RPC. It makes it sound a lot friendlier than it is, and encourages the wrong mental model in your head.

Also, a calculator is trivially modeled as RESTful.

Ответить
@dominikvonlavante6113
@dominikvonlavante6113 - 17.11.2023 10:19

I unfortunately simply do not see much use of gRPC in my domain of SPAs based business processes. Actions happen on business objects in the SPA, not really through the API. The API is there for validation, persistence and event based process guidance.

Ответить
@user-gj8fb8bl5g
@user-gj8fb8bl5g - 17.11.2023 09:21

it is difficult to set up. too many steps.
now if i were creating some microservices, and i wanted a very performant api client, i would think about grpc for sure. but if im building for a client, i'd stick to rest. grpc and protobuff have great performance boosts. however, everything comes at a price.

Ответить
@bhupeshparakh3355
@bhupeshparakh3355 - 17.11.2023 07:17

hey

Make a video of GRPC in Python , Please

Ответить
@lordnuada
@lordnuada - 17.11.2023 06:12

Rust gRPC examples please :)

Ответить