Created
November 29, 2021 16:42
-
-
Save p12s/2298bb21e1a53d9a1cbbf0cd54b90404 to your computer and use it in GitHub Desktop.
gRPC testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Evans | |
1. Добавляем в запсук сервера регистрацию reflection-сервиса: | |
```go | |
s := grpc.NewServer() | |
pb.RegisterCalculatorServiceServer(s, &server{}) // ваш автосгенерированный сервер | |
// register reflection service | |
reflection.Register(s) | |
``` | |
2. Устанавливаем утилиту Evans (репо https://github.com/ktr0731/evans): | |
MacOS: | |
``` | |
brew tap ktr0731/evans | |
brew install evans | |
``` | |
3. Запускаем сервер и evans (на порту сервера): | |
``` | |
go run server.go | |
evans -p 50051 -r // 50051 - порт на котором запущено ваше приложение, evans подключается к нему | |
``` | |
4. Используем команды для просмотра доступных методов: | |
![Evans](https://github.com/p-12s/own-golang-manual/blob/master/8-protobuf-grpc/udemy-protocol-buffers-3/04-calculator/evans.png?raw=true) | |
5. Тестируем сервер RPC без клиента: | |
``` | |
show service | |
service YOUR-SERVICE-NAME | |
call NAME (далее вводим данные и получаем результат) | |
``` | |
Дополнительно: | |
- Работает автодополнение выбора через Tab; | |
- Пользуйтесь командой help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment