gRPCurl и BloomRPC
Используйте мощные инструменты командной строки и GUI для взаимодействия с сервисами gRPC и их тестирования.
«gRPCurl и BloomRPC» — бесплатный урок gRPC & High Performance APIs на CoddyKit. Это урок 2 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения 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@latestgRPCurl: 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 listgRPCurl: 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.SayHellogRPCurl: 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.SayHelloIntroducing 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
.protofiles 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:
- Add Protobuf Definition: Load your
.protofiles (or an entire directory) into BloomRPC. - Select Service/Method: Choose the specific service and method you want to test from the sidebar.
- Edit Request: BloomRPC auto-generates a JSON template for the request message. Fill in the required data.
- Send Request: Click the 'Play' button to send the request to your gRPC server.
- 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» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс gRPC & High Performance APIs, подпишись на CoddyKit PRO. Курс gRPC & High Performance APIs содержит 4 уроков всего.
Чему я научусь в уроке «gRPCurl и BloomRPC»?
Используйте мощные инструменты командной строки и GUI для взаимодействия с сервисами gRPC и их тестирования. Ты практикуешь gRPC & High Performance APIs с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать gRPC & High Performance APIs?
Предыдущий опыт не требуется. gRPC & High Performance APIs на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 2 из 4.
Сколько времени занимает урок «gRPCurl и BloomRPC»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке gRPC & High Performance APIs?
Да. Каждый урок gRPC & High Performance APIs включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Интеграция gRPC-Web
- gRPCurl и BloomRPC
- Шаблоны обнаружения сервисов
- Отражение сервера и динамические клиенты