Use google.golang.org/protobuf instead of github.com/gogo/protobuf

This change replaces github.com/gogo/protobuf with
google.golang.org/protobuf, except for the code generators.

All proto-encoded structs are now generated from .proto files,
which include ttrpc.Request and ttrpc.Response.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato 2022-02-16 22:32:47 +00:00
parent 332f4c9a9b
commit d240c5005f
20 changed files with 1011 additions and 955 deletions

View File

@ -120,23 +120,20 @@ jobs:
sudo chmod -R go+rX /usr/local/include sudo chmod -R go+rX /usr/local/include
sudo chmod go+x /usr/local/bin/protoc sudo chmod go+x /usr/local/bin/protoc
- name: Install gogo/protobuf - name: Install protoc-gen-go
run: | run: |
cd $GOPATH/src go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
mkdir -p github.com/gogo
cd github.com/gogo
git clone --depth 1 --branch v1.3.2 https://github.com/gogo/protobuf
- name: Build protoc-gen-gogottrpc - name: Build protoc-gen-go-ttrpc
working-directory: src/github.com/containerd/ttrpc working-directory: src/github.com/containerd/ttrpc
run: | run: |
go build ./cmd/protoc-gen-gogottrpc go build ./cmd/protoc-gen-go-ttrpc
- name: Run Protobuild - name: Run Protobuild
working-directory: src/github.com/containerd/ttrpc working-directory: src/github.com/containerd/ttrpc
run: | run: |
export PATH=$GOPATH/bin:$PWD:$PATH export PATH=$GOPATH/bin:$PWD:$PATH
go install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf go install github.com/containerd/protobuild@7e5ee24bc1f70e9e289fef15e2631eb3491320bf
cd example
protobuild protobuild
(cd example && protobuild)
git diff --exit-code git diff --exit-code

19
Protobuild.toml Normal file
View File

@ -0,0 +1,19 @@
version = "2"
generators = ["go"]
# Control protoc include paths. Below are usually some good defaults, but feel
# free to try it without them if it works for your project.
[includes]
# Include paths that will be added before all others. Typically, you want to
# treat the root of the project as an include, but this may not be necessary.
before = ["."]
# Paths that will be added untouched to the end of the includes. We use
# `/usr/local/include` to pickup the common install location of protobuf.
# This is the default.
after = ["/usr/local/include"]
# This section maps protobuf imports to Go packages. These will become
# `-M` directives in the call to the go protobuf generator.
[packages]
"proto/status.proto" = "google.golang.org/genproto/googleapis/rpc/status"

View File

@ -27,10 +27,10 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/gogo/protobuf/proto"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
) )
// ErrClosed is returned by client methods when the underlying connection is // ErrClosed is returned by client methods when the underlying connection is

View File

@ -20,6 +20,8 @@ import (
"context" "context"
"testing" "testing"
"time" "time"
"github.com/containerd/ttrpc/internal"
) )
func TestUserOnCloseWait(t *testing.T) { func TestUserOnCloseWait(t *testing.T) {
@ -46,7 +48,7 @@ func TestUserOnCloseWait(t *testing.T) {
}), }),
) )
tp testPayload tp internal.TestPayload
tclient = newTestingClient(client) tclient = newTestingClient(client)
) )

View File

@ -19,7 +19,7 @@ package ttrpc
import ( import (
"fmt" "fmt"
"github.com/gogo/protobuf/proto" "google.golang.org/protobuf/proto"
) )
type codec struct{} type codec struct{}

View File

@ -1,6 +1,5 @@
version = "unstable" version = "2"
generator = "gogottrpc" generators = ["go", "go-ttrpc"]
plugins = ["ttrpc"]
# Control protoc include paths. Below are usually some good defaults, but feel # Control protoc include paths. Below are usually some good defaults, but feel
# free to try it without them if it works for your project. # free to try it without them if it works for your project.
@ -9,11 +8,6 @@ plugins = ["ttrpc"]
# treat the root of the project as an include, but this may not be necessary. # treat the root of the project as an include, but this may not be necessary.
# before = ["./protobuf"] # before = ["./protobuf"]
# Paths that should be treated as include roots in relation to the vendor
# directory. These will be calculated with the vendor directory nearest the
# target package.
packages = ["github.com/gogo/protobuf"]
# Paths that will be added untouched to the end of the includes. We use # Paths that will be added untouched to the end of the includes. We use
# `/usr/local/include` to pickup the common install location of protobuf. # `/usr/local/include` to pickup the common install location of protobuf.
# This is the default. # This is the default.
@ -22,11 +16,4 @@ plugins = ["ttrpc"]
# This section maps protobuf imports to Go packages. These will become # This section maps protobuf imports to Go packages. These will become
# `-M` directives in the call to the go protobuf generator. # `-M` directives in the call to the go protobuf generator.
[packages] [packages]
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
"google/rpc/status.proto" = "github.com/containerd/containerd/protobuf/google/rpc" "google/rpc/status.proto" = "github.com/containerd/containerd/protobuf/google/rpc"

View File

@ -26,7 +26,7 @@ import (
ttrpc "github.com/containerd/ttrpc" ttrpc "github.com/containerd/ttrpc"
"github.com/containerd/ttrpc/example" "github.com/containerd/ttrpc/example"
"github.com/gogo/protobuf/types" "google.golang.org/protobuf/types/known/emptypb"
) )
const socket = "example-ttrpc-server" const socket = "example-ttrpc-server"
@ -130,6 +130,6 @@ func (s *exampleServer) Method1(ctx context.Context, r *example.Method1Request)
}, nil }, nil
} }
func (s *exampleServer) Method2(ctx context.Context, r *example.Method1Request) (*types.Empty, error) { func (s *exampleServer) Method2(ctx context.Context, r *example.Method1Request) (*emptypb.Empty, error) {
return &types.Empty{}, nil return &emptypb.Empty{}, nil
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ syntax = "proto3";
package ttrpc.example.v1; package ttrpc.example.v1;
import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/containerd/ttrpc/example;example"; option go_package = "github.com/containerd/ttrpc/example;example";

View File

@ -0,0 +1,57 @@
// Code generated by protoc-gen-go-ttrpc. DO NOT EDIT.
// source: github.com/containerd/ttrpc/example/example.proto
package example
import (
context "context"
ttrpc "github.com/containerd/ttrpc"
empty "github.com/golang/protobuf/ptypes/empty"
)
type ExampleService interface {
Method1(ctx context.Context, req *Method1Request) (*Method1Response, error)
Method2(ctx context.Context, req *Method1Request) (*empty.Empty, error)
}
func RegisterExampleService(srv *ttrpc.Server, svc ExampleService) {
srv.Register("ttrpc.example.v1.Example", map[string]ttrpc.Method{
"Method1": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req Method1Request
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Method1(ctx, &req)
},
"Method2": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req Method1Request
if err := unmarshal(&req); err != nil {
return nil, err
}
return svc.Method2(ctx, &req)
},
})
}
type exampleClient struct {
client *ttrpc.Client
}
func NewExampleClient(client *ttrpc.Client) ExampleService {
return &exampleClient{
client: client,
}
}
func (c *exampleClient) Method1(ctx context.Context, req *Method1Request) (*Method1Response, error) {
var resp Method1Response
if err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method1", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}
func (c *exampleClient) Method2(ctx context.Context, req *Method1Request) (*empty.Empty, error) {
var resp empty.Empty
if err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method2", req, &resp); err != nil {
return nil, err
}
return &resp, nil
}

1
go.mod
View File

@ -4,6 +4,7 @@ go 1.13
require ( require (
github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.0
github.com/prometheus/procfs v0.6.0 github.com/prometheus/procfs v0.6.0
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c

164
internal/test.pb.go Normal file
View File

@ -0,0 +1,164 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.5.0
// source: github.com/containerd/ttrpc/test.proto
package internal
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type TestPayload struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Foo string `protobuf:"bytes,1,opt,name=foo,proto3" json:"foo,omitempty"`
Deadline int64 `protobuf:"varint,2,opt,name=deadline,proto3" json:"deadline,omitempty"`
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (x *TestPayload) Reset() {
*x = TestPayload{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_ttrpc_test_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TestPayload) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TestPayload) ProtoMessage() {}
func (x *TestPayload) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_ttrpc_test_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TestPayload.ProtoReflect.Descriptor instead.
func (*TestPayload) Descriptor() ([]byte, []int) {
return file_github_com_containerd_ttrpc_test_proto_rawDescGZIP(), []int{0}
}
func (x *TestPayload) GetFoo() string {
if x != nil {
return x.Foo
}
return ""
}
func (x *TestPayload) GetDeadline() int64 {
if x != nil {
return x.Deadline
}
return 0
}
func (x *TestPayload) GetMetadata() string {
if x != nil {
return x.Metadata
}
return ""
}
var File_github_com_containerd_ttrpc_test_proto protoreflect.FileDescriptor
var file_github_com_containerd_ttrpc_test_proto_rawDesc = []byte{
0x0a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e,
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x74, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65,
0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x74, 0x74, 0x72, 0x70, 0x63, 0x22,
0x57, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x10,
0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x66, 0x6f, 0x6f,
0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x03, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72,
0x64, 0x2f, 0x74, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_github_com_containerd_ttrpc_test_proto_rawDescOnce sync.Once
file_github_com_containerd_ttrpc_test_proto_rawDescData = file_github_com_containerd_ttrpc_test_proto_rawDesc
)
func file_github_com_containerd_ttrpc_test_proto_rawDescGZIP() []byte {
file_github_com_containerd_ttrpc_test_proto_rawDescOnce.Do(func() {
file_github_com_containerd_ttrpc_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_containerd_ttrpc_test_proto_rawDescData)
})
return file_github_com_containerd_ttrpc_test_proto_rawDescData
}
var file_github_com_containerd_ttrpc_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_github_com_containerd_ttrpc_test_proto_goTypes = []interface{}{
(*TestPayload)(nil), // 0: ttrpc.TestPayload
}
var file_github_com_containerd_ttrpc_test_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_github_com_containerd_ttrpc_test_proto_init() }
func file_github_com_containerd_ttrpc_test_proto_init() {
if File_github_com_containerd_ttrpc_test_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_containerd_ttrpc_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TestPayload); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_github_com_containerd_ttrpc_test_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_github_com_containerd_ttrpc_test_proto_goTypes,
DependencyIndexes: file_github_com_containerd_ttrpc_test_proto_depIdxs,
MessageInfos: file_github_com_containerd_ttrpc_test_proto_msgTypes,
}.Build()
File_github_com_containerd_ttrpc_test_proto = out.File
file_github_com_containerd_ttrpc_test_proto_rawDesc = nil
file_github_com_containerd_ttrpc_test_proto_goTypes = nil
file_github_com_containerd_ttrpc_test_proto_depIdxs = nil
}

5
proto/status.proto Normal file
View File

@ -0,0 +1,5 @@
syntax = "proto3";
message Status {
int32 code = 1;
}

396
request.pb.go Normal file
View File

@ -0,0 +1,396 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.5.0
// source: github.com/containerd/ttrpc/request.proto
package ttrpc
import (
status "google.golang.org/genproto/googleapis/rpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
TimeoutNano int64 `protobuf:"varint,4,opt,name=timeout_nano,json=timeoutNano,proto3" json:"timeout_nano,omitempty"`
Metadata []*KeyValue `protobuf:"bytes,5,rep,name=metadata,proto3" json:"metadata,omitempty"`
}
func (x *Request) Reset() {
*x = Request{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) {
return file_github_com_containerd_ttrpc_request_proto_rawDescGZIP(), []int{0}
}
func (x *Request) GetService() string {
if x != nil {
return x.Service
}
return ""
}
func (x *Request) GetMethod() string {
if x != nil {
return x.Method
}
return ""
}
func (x *Request) GetPayload() []byte {
if x != nil {
return x.Payload
}
return nil
}
func (x *Request) GetTimeoutNano() int64 {
if x != nil {
return x.TimeoutNano
}
return 0
}
func (x *Request) GetMetadata() []*KeyValue {
if x != nil {
return x.Metadata
}
return nil
}
type Response struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Status *status.Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
}
func (x *Response) Reset() {
*x = Response{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_github_com_containerd_ttrpc_request_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetStatus() *status.Status {
if x != nil {
return x.Status
}
return nil
}
func (x *Response) GetPayload() []byte {
if x != nil {
return x.Payload
}
return nil
}
type StringList struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
}
func (x *StringList) Reset() {
*x = StringList{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StringList) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StringList) ProtoMessage() {}
func (x *StringList) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use StringList.ProtoReflect.Descriptor instead.
func (*StringList) Descriptor() ([]byte, []int) {
return file_github_com_containerd_ttrpc_request_proto_rawDescGZIP(), []int{2}
}
func (x *StringList) GetList() []string {
if x != nil {
return x.List
}
return nil
}
type KeyValue struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
func (x *KeyValue) Reset() {
*x = KeyValue{}
if protoimpl.UnsafeEnabled {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KeyValue) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KeyValue) ProtoMessage() {}
func (x *KeyValue) ProtoReflect() protoreflect.Message {
mi := &file_github_com_containerd_ttrpc_request_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use KeyValue.ProtoReflect.Descriptor instead.
func (*KeyValue) Descriptor() ([]byte, []int) {
return file_github_com_containerd_ttrpc_request_proto_rawDescGZIP(), []int{3}
}
func (x *KeyValue) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *KeyValue) GetValue() string {
if x != nil {
return x.Value
}
return ""
}
var File_github_com_containerd_ttrpc_request_proto protoreflect.FileDescriptor
var file_github_com_containerd_ttrpc_request_proto_rawDesc = []byte{
0x0a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e,
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x74, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x74, 0x74, 0x72,
0x70, 0x63, 0x1a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x21,
0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x04,
0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4e, 0x61, 0x6e,
0x6f, 0x12, 0x2b, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4b, 0x65, 0x79, 0x56,
0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x45,
0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x06, 0x73, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70,
0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61,
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x20, 0x0a, 0x0a, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c,
0x69, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28,
0x09, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x32, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x56, 0x61,
0x6c, 0x75, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x1d, 0x5a, 0x1b, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69,
0x6e, 0x65, 0x72, 0x64, 0x2f, 0x74, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_github_com_containerd_ttrpc_request_proto_rawDescOnce sync.Once
file_github_com_containerd_ttrpc_request_proto_rawDescData = file_github_com_containerd_ttrpc_request_proto_rawDesc
)
func file_github_com_containerd_ttrpc_request_proto_rawDescGZIP() []byte {
file_github_com_containerd_ttrpc_request_proto_rawDescOnce.Do(func() {
file_github_com_containerd_ttrpc_request_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_containerd_ttrpc_request_proto_rawDescData)
})
return file_github_com_containerd_ttrpc_request_proto_rawDescData
}
var file_github_com_containerd_ttrpc_request_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_github_com_containerd_ttrpc_request_proto_goTypes = []interface{}{
(*Request)(nil), // 0: ttrpc.Request
(*Response)(nil), // 1: ttrpc.Response
(*StringList)(nil), // 2: ttrpc.StringList
(*KeyValue)(nil), // 3: ttrpc.KeyValue
(*status.Status)(nil), // 4: Status
}
var file_github_com_containerd_ttrpc_request_proto_depIdxs = []int32{
3, // 0: ttrpc.Request.metadata:type_name -> ttrpc.KeyValue
4, // 1: ttrpc.Response.status:type_name -> Status
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_github_com_containerd_ttrpc_request_proto_init() }
func file_github_com_containerd_ttrpc_request_proto_init() {
if File_github_com_containerd_ttrpc_request_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_github_com_containerd_ttrpc_request_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_containerd_ttrpc_request_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_containerd_ttrpc_request_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StringList); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_github_com_containerd_ttrpc_request_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*KeyValue); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_github_com_containerd_ttrpc_request_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_github_com_containerd_ttrpc_request_proto_goTypes,
DependencyIndexes: file_github_com_containerd_ttrpc_request_proto_depIdxs,
MessageInfos: file_github_com_containerd_ttrpc_request_proto_msgTypes,
}.Build()
File_github_com_containerd_ttrpc_request_proto = out.File
file_github_com_containerd_ttrpc_request_proto_rawDesc = nil
file_github_com_containerd_ttrpc_request_proto_goTypes = nil
file_github_com_containerd_ttrpc_request_proto_depIdxs = nil
}

29
request.proto Normal file
View File

@ -0,0 +1,29 @@
syntax = "proto3";
package ttrpc;
import "proto/status.proto";
option go_package = "github.com/containerd/ttrpc";
message Request {
string service = 1;
string method = 2;
bytes payload = 3;
int64 timeout_nano = 4;
repeated KeyValue metadata = 5;
}
message Response {
Status status = 1;
bytes payload = 2;
}
message StringList {
repeated string list = 1;
}
message KeyValue {
string key = 1;
string value = 2;
}

View File

@ -22,6 +22,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/containerd/ttrpc/internal"
"github.com/prometheus/procfs" "github.com/prometheus/procfs"
) )
@ -41,7 +42,7 @@ func TestUnixSocketHandshake(t *testing.T) {
registerTestingService(server, &testingServer{}) registerTestingService(server, &testingServer{})
var tp testPayload var tp internal.TestPayload
// server shutdown, but we still make a call. // server shutdown, but we still make a call.
if err := client.Call(ctx, serviceName, "Test", &tp, &tp); err != nil { if err := client.Call(ctx, serviceName, "Test", &tp, &tp); err != nil {
t.Fatalf("unexpected error making call: %v", err) t.Fatalf("unexpected error making call: %v", err)
@ -70,7 +71,7 @@ func BenchmarkRoundTripUnixSocketCreds(b *testing.B) {
go server.Serve(ctx, listener) go server.Serve(ctx, listener)
defer server.Shutdown(ctx) defer server.Shutdown(ctx)
var tp testPayload var tp internal.TestPayload
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
@ -96,7 +97,7 @@ func TestServerEOF(t *testing.T) {
registerTestingService(server, &testingServer{}) registerTestingService(server, &testingServer{})
tp := &testPayload{} tp := &internal.TestPayload{}
// do a regular call // do a regular call
if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil { if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil {
t.Fatalf("unexpected error during test call: %v", err) t.Fatalf("unexpected error during test call: %v", err)

View File

@ -17,20 +17,21 @@
package ttrpc package ttrpc
import ( import (
"bytes"
"context" "context"
"errors" "errors"
"fmt" "fmt"
"net" "net"
"reflect"
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
"testing" "testing"
"time" "time"
"github.com/gogo/protobuf/proto" "github.com/containerd/ttrpc/internal"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
) )
const serviceName = "testService" const serviceName = "testService"
@ -40,7 +41,7 @@ const serviceName = "testService"
// Typically, this is generated. We define it here to ensure that that package // Typically, this is generated. We define it here to ensure that that package
// primitive has what is required for generated code. // primitive has what is required for generated code.
type testingService interface { type testingService interface {
Test(ctx context.Context, req *testPayload) (*testPayload, error) Test(ctx context.Context, req *internal.TestPayload) (*internal.TestPayload, error)
} }
type testingClient struct { type testingClient struct {
@ -53,26 +54,16 @@ func newTestingClient(client *Client) *testingClient {
} }
} }
func (tc *testingClient) Test(ctx context.Context, req *testPayload) (*testPayload, error) { func (tc *testingClient) Test(ctx context.Context, req *internal.TestPayload) (*internal.TestPayload, error) {
var tp testPayload var tp internal.TestPayload
return &tp, tc.client.Call(ctx, serviceName, "Test", req, &tp) return &tp, tc.client.Call(ctx, serviceName, "Test", req, &tp)
} }
type testPayload struct {
Foo string `protobuf:"bytes,1,opt,name=foo,proto3"`
Deadline int64 `protobuf:"varint,2,opt,name=deadline,proto3"`
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3"`
}
func (r *testPayload) Reset() { *r = testPayload{} }
func (r *testPayload) String() string { return fmt.Sprintf("%+#v", r) }
func (r *testPayload) ProtoMessage() {}
// testingServer is what would be implemented by the user of this package. // testingServer is what would be implemented by the user of this package.
type testingServer struct{} type testingServer struct{}
func (s *testingServer) Test(ctx context.Context, req *testPayload) (*testPayload, error) { func (s *testingServer) Test(ctx context.Context, req *internal.TestPayload) (*internal.TestPayload, error) {
tp := &testPayload{Foo: strings.Repeat(req.Foo, 2)} tp := &internal.TestPayload{Foo: strings.Repeat(req.Foo, 2)}
if dl, ok := ctx.Deadline(); ok { if dl, ok := ctx.Deadline(); ok {
tp.Deadline = dl.UnixNano() tp.Deadline = dl.UnixNano()
} }
@ -90,7 +81,7 @@ func (s *testingServer) Test(ctx context.Context, req *testPayload) (*testPayloa
func registerTestingService(srv *Server, svc testingService) { func registerTestingService(srv *Server, svc testingService) {
srv.Register(serviceName, map[string]Method{ srv.Register(serviceName, map[string]Method{
"Test": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { "Test": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req testPayload var req internal.TestPayload
if err := unmarshal(&req); err != nil { if err := unmarshal(&req); err != nil {
return nil, err return nil, err
} }
@ -99,10 +90,16 @@ func registerTestingService(srv *Server, svc testingService) {
}) })
} }
func init() { func protoEqual(a, b proto.Message) (bool, error) {
proto.RegisterType((*testPayload)(nil), "testPayload") ma, err := proto.Marshal(a)
proto.RegisterType((*Request)(nil), "Request") if err != nil {
proto.RegisterType((*Response)(nil), "Response") return false, err
}
mb, err := proto.Marshal(b)
if err != nil {
return false, err
}
return bytes.Equal(ma, mb), nil
} }
func TestServer(t *testing.T) { func TestServer(t *testing.T) {
@ -136,8 +133,12 @@ func TestServer(t *testing.T) {
if result.err != nil { if result.err != nil {
t.Fatalf("(%s): %v", result.name, result.err) t.Fatalf("(%s): %v", result.name, result.err)
} }
if !reflect.DeepEqual(result.received, result.expected) { equal, err := protoEqual(result.received, result.expected)
t.Fatalf("(%s): unexpected response: %+#v != %+#v", result.name, result.received, result.expected) if err != nil {
t.Fatalf("failed to compare %s and %s: %s", result.received, result.expected, err)
}
if !equal {
t.Fatalf("unexpected response: %+#v != %+#v", result.received, result.expected)
} }
i++ i++
} }
@ -157,7 +158,7 @@ func TestServerUnimplemented(t *testing.T) {
errs <- server.Serve(ctx, listener) errs <- server.Serve(ctx, listener)
}() }()
var tp testPayload var tp internal.TestPayload
if err := client.Call(ctx, "Not", "Found", &tp, &tp); err == nil { if err := client.Call(ctx, "Not", "Found", &tp, &tp); err == nil {
t.Fatalf("expected error from non-existent service call") t.Fatalf("expected error from non-existent service call")
} else if status, ok := status.FromError(err); !ok { } else if status, ok := status.FromError(err); !ok {
@ -220,14 +221,14 @@ func TestServerShutdown(t *testing.T) {
// register a service that takes until we tell it to stop // register a service that takes until we tell it to stop
server.Register(serviceName, map[string]Method{ server.Register(serviceName, map[string]Method{
"Test": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { "Test": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
var req testPayload var req internal.TestPayload
if err := unmarshal(&req); err != nil { if err := unmarshal(&req); err != nil {
return nil, err return nil, err
} }
handlersStartedCloseOnce.Do(func() { close(handlersStarted) }) handlersStartedCloseOnce.Do(func() { close(handlersStarted) })
<-proceed <-proceed
return &testPayload{Foo: "waited"}, nil return &internal.TestPayload{Foo: "waited"}, nil
}, },
}) })
@ -240,7 +241,7 @@ func TestServerShutdown(t *testing.T) {
callwg.Add(1) callwg.Add(1)
go func(i int) { go func(i int) {
callwg.Done() callwg.Done()
tp := testPayload{Foo: "half" + fmt.Sprint(i)} tp := internal.TestPayload{Foo: "half" + fmt.Sprint(i)}
callErrs <- client.Call(ctx, serviceName, "Test", &tp, &tp) callErrs <- client.Call(ctx, serviceName, "Test", &tp, &tp)
}(i) }(i)
} }
@ -316,7 +317,7 @@ func TestOversizeCall(t *testing.T) {
registerTestingService(server, &testingServer{}) registerTestingService(server, &testingServer{})
tp := &testPayload{ tp := &internal.TestPayload{
Foo: strings.Repeat("a", 1+messageLengthMax), Foo: strings.Repeat("a", 1+messageLengthMax),
} }
if err := client.Call(ctx, serviceName, "Test", tp, tp); err == nil { if err := client.Call(ctx, serviceName, "Test", tp, tp); err == nil {
@ -351,7 +352,7 @@ func TestClientEOF(t *testing.T) {
registerTestingService(server, &testingServer{}) registerTestingService(server, &testingServer{})
tp := &testPayload{} tp := &internal.TestPayload{}
// do a regular call // do a regular call
if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil { if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
@ -380,7 +381,7 @@ func TestServerRequestTimeout(t *testing.T) {
addr, listener = newTestListener(t) addr, listener = newTestListener(t)
testImpl = &testingServer{} testImpl = &testingServer{}
client, cleanup = newTestClient(t, addr) client, cleanup = newTestClient(t, addr)
result testPayload result internal.TestPayload
) )
defer cancel() defer cancel()
defer cleanup() defer cleanup()
@ -391,7 +392,7 @@ func TestServerRequestTimeout(t *testing.T) {
go server.Serve(ctx, listener) go server.Serve(ctx, listener)
defer server.Shutdown(ctx) defer server.Shutdown(ctx)
if err := client.Call(ctx, serviceName, "Test", &testPayload{}, &result); err != nil { if err := client.Call(ctx, serviceName, "Test", &internal.TestPayload{}, &result); err != nil {
t.Fatalf("unexpected error making call: %v", err) t.Fatalf("unexpected error making call: %v", err)
} }
@ -417,7 +418,7 @@ func TestServerConnectionsLeak(t *testing.T) {
registerTestingService(server, &testingServer{}) registerTestingService(server, &testingServer{})
tp := &testPayload{} tp := &internal.TestPayload{}
// do a regular call // do a regular call
if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil { if err := client.Call(ctx, serviceName, "Test", tp, tp); err != nil {
t.Fatalf("unexpected error during test call: %v", err) t.Fatalf("unexpected error during test call: %v", err)
@ -466,7 +467,7 @@ func BenchmarkRoundTrip(b *testing.B) {
go server.Serve(ctx, listener) go server.Serve(ctx, listener)
defer server.Shutdown(ctx) defer server.Shutdown(ctx)
var tp testPayload var tp internal.TestPayload
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
@ -492,14 +493,14 @@ func checkServerShutdown(t *testing.T, server *Server) {
type callResult struct { type callResult struct {
name string name string
err error err error
input *testPayload input *internal.TestPayload
expected *testPayload expected *internal.TestPayload
received *testPayload received *internal.TestPayload
} }
func roundTrip(ctx context.Context, client *testingClient, name string) callResult { func roundTrip(ctx context.Context, client *testingClient, name string) callResult {
var ( var (
tp = &testPayload{ tp = &internal.TestPayload{
Foo: name, Foo: name,
} }
) )
@ -517,7 +518,7 @@ func roundTrip(ctx context.Context, client *testingClient, name string) callResu
return callResult{ return callResult{
name: name, name: name,
input: tp, input: tp,
expected: &testPayload{Foo: strings.Repeat(tp.Foo, 2), Metadata: name}, expected: &internal.TestPayload{Foo: strings.Repeat(tp.Foo, 2), Metadata: name},
received: resp, received: resp,
} }
} }

View File

@ -25,9 +25,9 @@ import (
"path" "path"
"unsafe" "unsafe"
"github.com/gogo/protobuf/proto"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
) )
type Method func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) type Method func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error)

11
test.proto Normal file
View File

@ -0,0 +1,11 @@
syntax = "proto3";
package ttrpc;
option go_package = "github.com/containerd/ttrpc/internal";
message TestPayload {
string foo = 1;
int64 deadline = 2;
string metadata = 3;
}

View File

@ -1,61 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ttrpc
import (
"fmt"
spb "google.golang.org/genproto/googleapis/rpc/status"
)
type Request struct {
Service string `protobuf:"bytes,1,opt,name=service,proto3"`
Method string `protobuf:"bytes,2,opt,name=method,proto3"`
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3"`
TimeoutNano int64 `protobuf:"varint,4,opt,name=timeout_nano,proto3"`
Metadata []*KeyValue `protobuf:"bytes,5,rep,name=metadata,proto3"`
}
func (r *Request) Reset() { *r = Request{} }
func (r *Request) String() string { return fmt.Sprintf("%+#v", r) }
func (r *Request) ProtoMessage() {}
type Response struct {
Status *spb.Status `protobuf:"bytes,1,opt,name=status,proto3"`
Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3"`
}
func (r *Response) Reset() { *r = Response{} }
func (r *Response) String() string { return fmt.Sprintf("%+#v", r) }
func (r *Response) ProtoMessage() {}
type StringList struct {
List []string `protobuf:"bytes,1,rep,name=list,proto3"`
}
func (r *StringList) Reset() { *r = StringList{} }
func (r *StringList) String() string { return fmt.Sprintf("%+#v", r) }
func (r *StringList) ProtoMessage() {}
type KeyValue struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3"`
Value string `protobuf:"bytes,2,opt,name=value,proto3"`
}
func (m *KeyValue) Reset() { *m = KeyValue{} }
func (*KeyValue) ProtoMessage() {}
func (m *KeyValue) String() string { return fmt.Sprintf("%+#v", m) }