1.Apa itu gRPC?
Bahasa Indonesia
Sejarah gRPC
● Tahun 2015 Google mempublikasikan gRPC,
yang sekarang digunakan di banyak organisasi di
luar Google untuk memberdayakan kasus
penggunaan dari microservice. gRPC
menggunakan HTTP/2 untuk transport, Protocol
Buffers untuk interface description language,and
memiliki fitur authentication, bidirectional
streaming and flow control, blocking atau
nonblocking bindings, dan cancellation dan
timeouts. gRPC juga generate cross-platform
client dan server bindings untuk banyak bahasa
pemrograman
● gRPC kepanjangan dari Google Remote
Procedure call.
● gRPC adalah teknik remote procedure call (RPC)
yang membawa fitur-fitur modern ke aplikasi client
- server.
● gRPC dapat memanggil fungsi langsung di
komputer yang lain walaupun menggunakan
bahasa pemrograman yang berbeda
Source https://grpc.io/docs/what-is-grpc/introduction/
Bahasa yang official support gRPC
● C# / .NET
● C++
● Dart
● Go
● Java
● Kotlin
● Node
● Objective-C
● PHP
● Python
● Ruby
https://grpc.io/docs/languages/
HTTP 2.0
Source: https://freecontent.manning.com/animation-http-1-1-vs-http-2-vs-http-2-with-push/
Protocol Buffer
Source: https://www.xenonstack.com/insights/google-protocol-buffer/
https://medium.com/@philipshen13/a-short-introduction-to-grpc-419b620e2177
gRPC API Service Method
1. A unary service method takes one input and
returns one output.
2. A server streaming service method receives
one input from the client and sends a stream
of outputs. It can also send back multiple
outputs as data becomes available.
3. Client streaming service methods open a
connection to a server, and then when the
server acknowledges the stream can begin,
the client side can begin sending data until it
terminates the stream.
4. Bidirectional streaming service methods
simultaneously send and receive data
streams in both directions.
Source: https://blog.knoldus.com/unary-streaming-via-grpc/
gRPC Flow
pic source:https://blog.bytebytego.com/p/ep32-how-does-grpc-work
Step 1: A REST call is made from the client. The request
body is usually in JSON format.
Steps 2 - 4: The order service (gRPC client) receives the
REST call, transforms it, and makes an RPC call to the
payment service. gPRC encodes the client stub into a
binary format and sends it to the low-level transport layer.
Step 5: gRPC sends the packets over the network via
HTTP2. Because of binary encoding and network
optimizations, gRPC is said to be 5X faster than JSON.
Steps 6 - 8: The payment service (gRPC server) receives
the packets from the network, decodes them, and invokes
the server application.
Steps 9 - 11: The result is returned from the server
application, and gets encoded and sent to the transport
layer.
Steps 12 - 14: The order service receives the packets,
decodes them, and sends the result to the client application.
Tools testing gRPC (1) : postman
https://blog.postman.com/postman-now-supports-grpc/
Tools testing gRPC (2) : BloomRPC
https://github.com/bloomrpc/bloomrpc
Tools testing gRPC (3) : gRPCCurl
https://github.com/fullstorydev/grpcurl
02. Instalasi gRPC dengan GO
Bahasa Indonesia
Instalasi
1. Golang versi terakhir
https://go.dev/doc/devel/release
2. Protocol Buffer compiler
https://github.com/protocolbuffers/protobuf/releases
1. Go plugins for the protocol compiler
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
Instalasi protocol buffer (1)
1. kunjungi https://github.com/protocolbuffers/protobuf/releases
2. download binary
3. setting environment variable
Instalasi protocol buffer (2)
Instalasi protocol buffer (3)
Instalasi protocol buffer (4)
$ git clone -b v1.50.0 --depth 1 https://github.com/grpc/grpc-go
$ go run greeter_server/main.go
download contoh project
run server grpc
run server client
$ go run greeter_client/main.go
Generate proto
$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-
grpc_opt=paths=source_relative helloworld/helloworld.proto

Apa itu gRPC_.pptx

  • 1.
  • 2.
    Sejarah gRPC ● Tahun2015 Google mempublikasikan gRPC, yang sekarang digunakan di banyak organisasi di luar Google untuk memberdayakan kasus penggunaan dari microservice. gRPC menggunakan HTTP/2 untuk transport, Protocol Buffers untuk interface description language,and memiliki fitur authentication, bidirectional streaming and flow control, blocking atau nonblocking bindings, dan cancellation dan timeouts. gRPC juga generate cross-platform client dan server bindings untuk banyak bahasa pemrograman ● gRPC kepanjangan dari Google Remote Procedure call. ● gRPC adalah teknik remote procedure call (RPC) yang membawa fitur-fitur modern ke aplikasi client - server. ● gRPC dapat memanggil fungsi langsung di komputer yang lain walaupun menggunakan bahasa pemrograman yang berbeda Source https://grpc.io/docs/what-is-grpc/introduction/
  • 3.
    Bahasa yang officialsupport gRPC ● C# / .NET ● C++ ● Dart ● Go ● Java ● Kotlin ● Node ● Objective-C ● PHP ● Python ● Ruby https://grpc.io/docs/languages/
  • 4.
  • 5.
  • 6.
    gRPC API ServiceMethod 1. A unary service method takes one input and returns one output. 2. A server streaming service method receives one input from the client and sends a stream of outputs. It can also send back multiple outputs as data becomes available. 3. Client streaming service methods open a connection to a server, and then when the server acknowledges the stream can begin, the client side can begin sending data until it terminates the stream. 4. Bidirectional streaming service methods simultaneously send and receive data streams in both directions. Source: https://blog.knoldus.com/unary-streaming-via-grpc/
  • 7.
    gRPC Flow pic source:https://blog.bytebytego.com/p/ep32-how-does-grpc-work Step1: A REST call is made from the client. The request body is usually in JSON format. Steps 2 - 4: The order service (gRPC client) receives the REST call, transforms it, and makes an RPC call to the payment service. gPRC encodes the client stub into a binary format and sends it to the low-level transport layer. Step 5: gRPC sends the packets over the network via HTTP2. Because of binary encoding and network optimizations, gRPC is said to be 5X faster than JSON. Steps 6 - 8: The payment service (gRPC server) receives the packets from the network, decodes them, and invokes the server application. Steps 9 - 11: The result is returned from the server application, and gets encoded and sent to the transport layer. Steps 12 - 14: The order service receives the packets, decodes them, and sends the result to the client application.
  • 8.
    Tools testing gRPC(1) : postman https://blog.postman.com/postman-now-supports-grpc/
  • 9.
    Tools testing gRPC(2) : BloomRPC https://github.com/bloomrpc/bloomrpc
  • 10.
    Tools testing gRPC(3) : gRPCCurl https://github.com/fullstorydev/grpcurl
  • 11.
    02. Instalasi gRPCdengan GO Bahasa Indonesia
  • 12.
    Instalasi 1. Golang versiterakhir https://go.dev/doc/devel/release 2. Protocol Buffer compiler https://github.com/protocolbuffers/protobuf/releases 1. Go plugins for the protocol compiler $ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 $ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
  • 13.
    Instalasi protocol buffer(1) 1. kunjungi https://github.com/protocolbuffers/protobuf/releases 2. download binary 3. setting environment variable
  • 14.
  • 15.
  • 16.
    Instalasi protocol buffer(4) $ git clone -b v1.50.0 --depth 1 https://github.com/grpc/grpc-go $ go run greeter_server/main.go download contoh project run server grpc run server client $ go run greeter_client/main.go
  • 17.
    Generate proto $ protoc--go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go- grpc_opt=paths=source_relative helloworld/helloworld.proto