Preface
How do you usually gRPC
There are often the following methods:
- Write single test code to simulate client test by yourself.
- You can take a
gRPC-Gateway
service, which can be simulatedpostman
But these two methods are not particularly elegant; the first method is not very intuitive to maintain in the code when the request structure nesting is particularly complicated; and the code will be particularly long.
The second method is the same as requesting the HTTP interface in postman, which looks very intuitive; but it needs to maintain a gRPC-Gateway
service, and at the same time, the interface definition has to be republished when the interface definition changes, which is slightly more complicated to use.
So after some searching, I found two tools that looked good:
First look at the BloomRPC
page, which is beautiful and well-functioning; but there is a very uncomfortable place, that is, it does not support the int64
data request, and there will be accuracy problems.
Here I wrote a simple interface to directly return the requested int64
.
func (o *Order) Create(ctx context.Context, in *v1.OrderApiCreate) (*v1.Order, error) {
fmt.Println(in.OrderId)
return &v1.Order{
OrderId: in.OrderId,
Reason: nil,
}, nil
}
You will find that the accuracy of the data received by the server has been lost.
This is very uncomfortable in our int64
a lot, and most of the interfaces are unusable.
grpcui
is a BloomRPC
for a period of time, and the function is relatively complete; the accuracy problem in BloomRPC
But because I was used BloomRPC
before, and my browser almost opened dozens of tap pages during the daily development process, it was not so convenient to grpcui
So I wondered if there could be a stand-alone APP BloomRPC
and also support tools int64
Prepare
After looking around, it seems that I didn't find it. Just some time ago, I wrote a gRPC
. In fact, the core function required by the APP, which is the generalized call, has been implemented.
Since the core capabilities are implemented in Go, this APP is best written in Go, so that it will be more convenient to reuse the code; I just want to see how Go can be used to implement GUI applications.
Unfortunately, Go does not provide native GUI library support. Finally, searched and
From star
, it is more used, and it also supports cross-platform packaging; so I finally decided to use this library to build this application.
Core functions
BloomRPC
entire App interaction process, but as a back-end development that does not understand aesthetics and design, the most difficult part in the whole process is the layout.
This is the first version of the page I spent several nights debugging. Although it works, it is very inconvenient to view the request and response data.
So it took another weekend and the final version is as follows (at first glance it seems no difference):
Although there is still a certain gap between the page and BloomRPC
, it does not affect the use; the key is int64
the problem of 061a41f1e51056 is solved; you can happily press the code again.
Install
Friends who have similar needs and want to experience it can download and use here:
https://github.com/crossoverJie/ptg/releases/download/0.0.2/ptg-mac-gui.tar
Since I don’t have a Windows
computer at the moment, there is no packaged exe program; friends with related needs can download the source code and compile it:
git clone git@github.com:crossoverJie/ptg.git
cd ptg
make pkg-win
Follow-up plan
The function of the current version is still relatively simple, only supports the commonly used unary
calls; follow-up will gradually add stream
, metadata
, workspace storage and restoration.
Suggestions on pages and interactions are also welcome.
Originally I was going to upload it to brew
for easy installation, but I was rejected all night because of insufficient data, so if you are helpful or interested, please help me a little bit of attention (I have a feeling of live streaming 🐶)
Source address: https://github.com/crossoverJie/ptg
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。