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

REST in Peace. Long live gRPC! @ JOTB22

REST in Peace. Long live gRPC! @ JOTB22

Many teams are still struggling to implement good APIs, forcing RPC use cases into a semi RESTful world. Modern and efficient IPC is more than just doing REST. Take Kubernetes as example: REST on the outside, gRPC on the inside. We should use this approach for enterprise applications as well.

This session focuses on modern and efficient Inter Process Communication (IPC) for microservices. We start with a REST API, built using JAX-RS and Quarkus to briefly discuss the pros and cons of this approach. Then, we will extend the API with an efficient Protobuf payload representation in order to finally transform the API into a fully fledged high-performance gRPC interface definition. But that’s not all! To put some extra icing on the cake, this talk will demonstrate how to consume the gRPC service from a JavaScript web client and also how to completely generate a matching REST API from an enhanced gRPC interface definition to ensure full interoperability in a microservice architecture.
#qaware #cloudnativenerd

M.-Leander Reimer

April 28, 2022
Tweet

More Decks by M.-Leander Reimer

Other Decks in Programming

Transcript

  1. %KIRHE 5(67%HHU 6HUYLFH 5(67%HHU 6HUYLFH ++'$/$*)‰%.*) ++'$/$*)‰3g+-*/*0! J53&%HHU 6HUYLFH J53&%HHU

    6HUYLFH J53&%HHU :HE8, J53&%HHU &OLHQW J53&5(67 *DWHZD\ ++'$/$*)‰%.*) J53&/% 1JLQ[ K64' K64' K64' K64' K64' ;IF9- J53&:HE (QYR\ 8]TI7GVMTX
  2. $4XLFN+LVWRU\/HVVRQRQ,3&  =6 ð÷ĦïøĦðøøõ c—©øô JG ðóĦïðĦðøöõ J Ōöïö JNT

    ñïïï }ÛŌJ¯ÛŌTĦŌ —‡£ƒ—©‘ .rÔrŌJ6& ‡}Ōðøøö ./ŌðĦð $TTGijðĦï 6r—Ōðøøõ J Ōðøóô $TTGijðĦð .Ë©—Ōðøøø J Ōñõðõ $TTGijñĦï 6r—Ōñïðô J Ōöôóï N=GŌðĦñ ñïïò JG =~ÆŌðø÷ò —¼¼‡£ŌË©ƒŌ 7—‡£À¯© =J ŌðĦï =~ÆŌðøøð =J ŌñĦï ˑËÀÆŌðøøõ =J Ōñ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VSNIGXWJVSQXLIK64'IGSW]WXIQIREFPIKSSHMRXIVSTIVEFMPMX] ƍ K64'+EXI[E]LXXTWKVTGIGSW]WXIQKMXLYFMSKVTGKEXI[E] ƍ K64';IFLXXTWKVTGMSHSGWTPEXJSVQW[IFUYMGOWXEVX
  10. .4)/3Ѕ̲+-*/*̡̲̫ *+/$*)%1͔+&" Ѕ̲#).̨*)̨"-+̲̫ *+/$*)%1͔*0/ -͔'..)( Ѕ̲ --*/*.̲̫ $(+*-/̲"**"' ͞+-*/*0!͞ (+/4̨+-*/*̲̫

    +&"  -̫ . -1$  - -1$ ͜ -+'' -.͘"**"' ̨+-*/*0!̨(+/4͙- /0-).͘ / -. .+*). ͙͜͝ -+ / -͘ / - ,0 ./͙- /0-).͘ / - .+*). ͙͜͝ -+- /  -͘- /  - ,0 ./͙- /0-).͘"**"' ̨+-*/*0!̨(+/4͙͜͝ -++/  -͘+/  - ,0 ./͙- /0-).͘"**"' ̨+-*/*0!̨(+/4͙͜͝ -+ ' /  -͘ ' /  - ,0 ./͙- /0-).͘"**"' ̨+-*/*0!̨(+/4͙͜͝ ͝ ͞͞(*- -*/*0!( .."  !$)$/$*).̨̨̨
  11. %KIRHE 5(67%HHU 6HUYLFH 5(67%HHU 6HUYLFH ++'$/$*)‰%.*) ++'$/$*)‰3g+-*/*0! J53&%HHU 6HUYLFH J53&%HHU

    6HUYLFH J53&%HHU :HE8, J53&%HHU &OLHQW J53&5(67 *DWHZD\ ++'$/$*)‰%.*) J53&/% 1JLQ[ K64' K64' K64' K64' K64' ;IF9- J53&:HE (QYR\ 8]TI7GVMTX
  12. $(+*-/̲"**"' ͞+-*/*0!͞ (+/4̨+-*/*̲̫ $(+*-/̲"**"' ͞+$͞))*//$*).̨+-*/*̲̫ . -1$  - -1$

    ͜ -+'' -.͘"**"' ̨+-*/*0!̨(+/4͙- /0-).͘ / -. .+*). ͙͜ *+/$*)͘"**"' ̨+$̨#//+͙Ѕ͜" /̪̲͞+$͞ -.̲̫͝ ͝ -+ / -͘ / - ,0 ./͙- /0-).͘ / - .+*). ͙͜ *+/$*)͘"**"' ̨+$̨#//+͙Ѕ͜ " /̪̲͞+$͞ -.͜͞.$)̲͝ - .+*). ͔*4̪̲ -̲ ̫͝ ͝ -+- /  -͘- /  - ,0 ./͙- /0-).͘"**"' ̨+-*/*0!̨(+/4͙͜ *+/$*)͘"**"' ̨+$̨#//+͙Ѕ͜ +*./̪̲͞+$͞ -.̲ *4̪̲̲͢ ̫͝ ͝ ͞͞(*-  !$)$/$*).̬ ͝