際際滷

際際滷Share a Scribd company logo
gRPC Services Testing
What is gRPC ?
Remote Procedure Calls
Protocol developed by Google
Client communicates with the server by calling functions defined on the API as if they were
local.
Increasingly popular on microservices architecture for internal service communications
Where data from the service is not directly consumed by a web browser
Faster, efficient protocol with lesser network overhead - built on top of Http2 (connection
reuse,parallel requests) and protobuff
RPC - Working
gRPC client talks to server via gRPC channel
gRPC sends request(s) to the server and returns the servers
protocol buffer response(s) to the client.
gRPC uses protocol buffers (created by Google) as the data
interchange format
Unlike JSON, protocol buffers are a binary Interface Definition
Language (IDL) which makes it much faster for computers to
process.
Calls can be synchronous or asynchronous
Client and server in different languages
Protobuff
 Proto file - defines how the client and
server can communicate and with what
information
 Protoc compiler generates the client code
required to talk to server from .proto file
 Takes care of serializing and deserializing
the requests and responses.
Accessing rpc services
Using gRPC CLI - Polyglot
Commands:
List_services
java -jar ~/Downloads/polyglot.jar --command=list_services --endpoint=localhost:50051
--proto_discovery_root="./proto"
Call
echo "{'name': 'World'}" | java -jar ~/Downloads/polyglot.jar --command=call
--full_method=helloworld.Greeter/SayHello --endpoint=localhost:50051
--proto_discovery_root="./proto" --deadline_ms=3000
Accessing rpc service programmatically
Test the API as a whole unit in itself - seeing it as a black box that accepts a request and
returns a response

More Related Content

gRPC services testing

  • 2. What is gRPC ? Remote Procedure Calls Protocol developed by Google Client communicates with the server by calling functions defined on the API as if they were local. Increasingly popular on microservices architecture for internal service communications Where data from the service is not directly consumed by a web browser Faster, efficient protocol with lesser network overhead - built on top of Http2 (connection reuse,parallel requests) and protobuff
  • 3. RPC - Working gRPC client talks to server via gRPC channel gRPC sends request(s) to the server and returns the servers protocol buffer response(s) to the client. gRPC uses protocol buffers (created by Google) as the data interchange format Unlike JSON, protocol buffers are a binary Interface Definition Language (IDL) which makes it much faster for computers to process. Calls can be synchronous or asynchronous Client and server in different languages
  • 4. Protobuff Proto file - defines how the client and server can communicate and with what information Protoc compiler generates the client code required to talk to server from .proto file Takes care of serializing and deserializing the requests and responses.
  • 5. Accessing rpc services Using gRPC CLI - Polyglot Commands: List_services java -jar ~/Downloads/polyglot.jar --command=list_services --endpoint=localhost:50051 --proto_discovery_root="./proto" Call echo "{'name': 'World'}" | java -jar ~/Downloads/polyglot.jar --command=call --full_method=helloworld.Greeter/SayHello --endpoint=localhost:50051 --proto_discovery_root="./proto" --deadline_ms=3000
  • 6. Accessing rpc service programmatically Test the API as a whole unit in itself - seeing it as a black box that accepts a request and returns a response