Upgrade to Pro — share decks privately, control downloads, hide ads and more …

.NET Day 22 - Getting a gRIP on ASP.NET Core gRPC by Roland Guijt

dotnetday
September 03, 2022

.NET Day 22 - Getting a gRIP on ASP.NET Core gRPC by Roland Guijt

What's that in the sky? Is it a plane? Is it WCF? No it's better. It's gRPC that's now natively supported in ASP.NET Core. It uses the same underlying RPC principle of the good ol' WCF. Furthermore, it's just implemented better, it's more efficient, and it is way, way faster. That makes it very suitable for communication between microservices, for example. In this session I'm talking about what gRPC is but also how you can implement it right away in any ASP.NET Core application. I'll not only do that by building a gRPC endpoint into an existing ASP.NET Core application, but you'll also learn that on the consuming side, there is also a lot to like. You'll leave with the ability to create and consume APIs on steroids.

dotnetday

September 03, 2022
Tweet

More Decks by dotnetday

Other Decks in Technology

Transcript

  1. @rolandguijt rolandguijt.com MVP | CONSULTANT | TRAINER | PLURALSIGHT AUTHOR

    Roland Guijt Getting a gRIP on ASP.NET Core gRPC
  2. What is gRPC? Open source RPC framework HTTP/2 and Protocol

    Buffers High performance Platform independent Contract first
  3. HTTP/2: Streams, Header Separation Client Server TCP socket HEADERS frame

    DATA frame HEADERS frame DATA frame DATA frame HEADERS frame
  4. REST Content first (URLs, HTTP method, JSON) Content is readable

    Utilizes HTTP gRPC Contract first (proto file) Contract is readable Hides remoting complexity using RPC REST APIs vs gRPC APIs Based on a slide by James Newton King
  5. gRPC with Protocol Buffers virtual Foo() {} Client.Foo() ASP.NET Core

    Server Client Proto { Foo() } ProtoBuf Proto { Foo() }
  6. REST with JSON Client Server GET /product/1 200 { name

    = "Socks", price = 2 } Deserialize
  7. gRPC with ProtoBuf Client Server binary: 1 = 1 binary:

    1 = 1 2 = "Socks", 3 = 2 Product Response ProductRequest ProductRequest Product Response Proto { int id = 1, string name = 2, string price = 3 }
  8. Most Used Status Codes GRPC_STATUS_UNIMPLEMENTED Method not implemented. GRPC_STATUS_UNAVAILABLE Problem

    with the service. GRPC_STATUS_UNKNOWN Invalid response. GRPC_STATUS_INTERNAL Problem with encoding/decoding. GRPC_STATUS_UNAUTHENTICATEDAuthentication failed. GRPC_STATUS_PERMISSION_DENIED Authorization failed. GRPC_STATUS_CANCELLED Call was canceled.