0Pricing
gRPC & High Performance APIs · 课时

gRPCurl 与 BloomRPC

利用功能强大的命令行和图形用户界面工具与 gRPC 服务交互并进行测试

gRPCurl 与 BloomRPC 是 CoddyKit 上的免费 gRPC & High Performance APIs 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 gRPC & High Performance APIs 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 gRPC & High Performance APIs 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Why Test gRPC Services?

When building gRPC services, it's crucial to have tools that let you easily test and interact with them. Unlike REST APIs, which often use HTTP clients like Postman or curl, gRPC uses a binary protocol (Protobuf over HTTP/2) that traditional tools can't understand.

This lesson introduces two popular tools: gRPCurl for command-line interaction and BloomRPC for a user-friendly graphical interface.

Meet gRPCurl: CLI for gRPC

gRPCurl is a powerful command-line tool that lets you interact with gRPC servers. Think of it as curl, but specifically designed for gRPC.

  • It can list services and methods exposed by a gRPC server.
  • It can describe the Protobuf message types used by these methods.
  • It can invoke RPC methods with arbitrary Protobuf messages.

It's incredibly useful for quick testing, scripting, and debugging.

Installing gRPCurl

gRPCurl is a single binary, making it easy to install. You can download pre-compiled binaries from its GitHub releases page for your operating system (Linux, macOS, Windows).

Alternatively, if you have Go installed, you can install it using the Go toolchain:

go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest

gRPCurl: Listing Services

Once installed, you can use gRPCurl to inspect a running gRPC server. Let's imagine a simple Greeter service running on localhost:50051. First, we can list the available services:

grpcurl localhost:50051 list

gRPCurl: Describing Methods

To understand what a specific service or method expects, you can use the describe command. This shows you the Protobuf schema for the inputs and outputs.

For our Greeter service, let's describe the SayHello method:

grpcurl localhost:50051 describe helloworld.Greeter.SayHello

gRPCurl: Invoking a Unary RPC

Now, let's actually call the SayHello method. We need to specify the server address, the method name, and the input data as a JSON payload using the -d flag.

The -plaintext flag is used if your server is not using TLS/SSL (common for local development).

grpcurl -plaintext -d '{"name": "CoddyKit"}' localhost:50051 helloworld.Greeter.SayHello

Introducing BloomRPC: GUI for gRPC

While gRPCurl is great for scripting, sometimes a graphical user interface (GUI) makes testing more intuitive. BloomRPC is a popular open-source GUI client for gRPC services.

It provides a visual way to interact with your services, similar to how Postman works for REST APIs.

BloomRPC: Key Features

BloomRPC simplifies gRPC testing with several user-friendly features:

  • Schema Discovery: Imports .proto files to automatically discover services and methods.
  • Request Editor: Provides an intuitive JSON editor for constructing request messages.
  • Response Viewer: Displays server responses clearly.
  • History: Keeps a record of past requests, making it easy to re-run or modify them.
  • Streaming Support: Handles all four gRPC communication patterns (unary, server, client, bidirectional streaming).

Using BloomRPC for Unary Calls

To use BloomRPC, you typically:

  1. Add Protobuf Definition: Load your .proto files (or an entire directory) into BloomRPC.
  2. Select Service/Method: Choose the specific service and method you want to test from the sidebar.
  3. Edit Request: BloomRPC auto-generates a JSON template for the request message. Fill in the required data.
  4. Send Request: Click the 'Play' button to send the request to your gRPC server.
  5. View Response: The server's response will be displayed in the response panel.

Tooling Test

Which of the following statements about gRPCurl and BloomRPC are true?

Recap: gRPC Testing Essentials

In this lesson, we explored two essential tools for working with gRPC services:

  • gRPCurl: A versatile command-line tool for scripting, debugging, and quick interactions with gRPC servers.
  • BloomRPC: A user-friendly graphical interface that simplifies testing with visual schema discovery and request/response editing.

Mastering these tools will significantly boost your productivity when developing and troubleshooting gRPC-based applications. They provide different but equally valuable approaches to ensure your gRPC services are working as expected.

常见问题解答

「gRPCurl 与 BloomRPC」课时是免费的吗?

是的 — 「gRPCurl 与 BloomRPC」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 gRPC & High Performance APIs 课程的其余内容,请升级到 CoddyKit PRO。 gRPC & High Performance APIs 课程共包含 4 节课。

「gRPCurl 与 BloomRPC」这节课中我会学到什么?

利用功能强大的命令行和图形用户界面工具与 gRPC 服务交互并进行测试 你通过在浏览器中直接运行的动手代码来练习 gRPC & High Performance APIs,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 gRPC & High Performance APIs 需要有经验吗?

无需任何先前经验。CoddyKit 上的 gRPC & High Performance APIs 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。

「gRPCurl 与 BloomRPC」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 gRPC & High Performance APIs 课中编写并运行代码吗?

能。每节 gRPC & High Performance APIs 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. gRPC-Web 集成
  2. gRPCurl 与 BloomRPC
  3. 服务发现模式
  4. 服务器反射与动态客户端
← 返回 gRPC & High Performance APIs