【文件属性】:
文件名称:go-grpc-net-conn:将任何gRPC流转换为Go`net.Conn`实现
文件大小:13KB
文件格式:ZIP
更新时间:2021-04-14 22:36:10
Go
go-grpc-net-conn
go-grpc-net-conn是一个Go库,可在gRPC流的顶部创建net.Conn实现。 如果流是双向的(RPC的请求和响应都是流),则net.Conn是。
安装
标准go get :
$ go get github.com/mitchellh/go-grpc-net-conn
用法与范例
有关用法和示例,请参见 。
一个简短的例子如下所示。 请注意,唯一的次要复杂性是填充Conn结构的必填字段。 该程序包需要知道如何在预期的protobuf消息类型上对字节片进行编码和解码。
想象一下一个如下所示的protobuf服务:
syntax = "proto3" ;
package example ;
service ExampleService {
rpc Stream(stream Bytes) returns (stream Bytes)
【文件预览】:
go-grpc-net-conn-master
----go.mod(223B)
----conn.go(5KB)
----go.sum(6KB)
----testproto()
--------testproto.go(83B)
--------test.pb.go(5KB)
--------test.proto(152B)
----LICENSE(1KB)
----README.md(2KB)
----encode.go(2KB)
----conn_helpers_test.go(2KB)
----conn_test.go(2KB)