ttrpc: update examples after name change
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
f147d6ca77
commit
bd8c759c72
@ -1,6 +1,6 @@
|
||||
version = "unstable"
|
||||
generator = "gogomgrpc"
|
||||
plugins = ["mgrpc"]
|
||||
generator = "gogottrpc"
|
||||
plugins = ["ttrpc"]
|
||||
|
||||
# Control protoc include paths. Below are usually some good defaults, but feel
|
||||
# free to try it without them if it works for your project.
|
||||
|
@ -1,4 +1,4 @@
|
||||
# mgrpc
|
||||
# ttrpc
|
||||
|
||||
GRPC for low-memory environments.
|
||||
|
||||
@ -19,8 +19,8 @@ GRPC services, as they do not speak the same protocol.
|
||||
# Usage
|
||||
|
||||
Create a gogo vanity binary (see
|
||||
[`cmd/protoc-gen-gogomgrpc/main.go`](cmd/protoc-gen-gogomgrpc/main.go) for an
|
||||
example with the mgrpc plugin enabled.
|
||||
[`cmd/protoc-gen-gogottrpc/main.go`](cmd/protoc-gen-gogottrpc/main.go) for an
|
||||
example with the ttrpc plugin enabled.
|
||||
|
||||
It's recommended to use [`protobuild`](https://github.com/stevvooe/protobuild)
|
||||
to build the protobufs for this project, but this will work with protoc
|
||||
|
@ -22,12 +22,12 @@ import google_protobuf1 "github.com/gogo/protobuf/types"
|
||||
import _ "github.com/gogo/protobuf/gogoproto"
|
||||
import _ "github.com/gogo/protobuf/types"
|
||||
|
||||
import context "context"
|
||||
import github_com_stevvooe_ttrpc "github.com/stevvooe/ttrpc"
|
||||
|
||||
import strings "strings"
|
||||
import reflect "reflect"
|
||||
|
||||
import context "context"
|
||||
import github_com_stevvooe_ttrpc "github.com/stevvooe/ttrpc"
|
||||
|
||||
import io "io"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -183,42 +183,6 @@ func encodeVarintExample(dAtA []byte, offset int, v uint64) int {
|
||||
dAtA[offset] = uint8(v)
|
||||
return offset + 1
|
||||
}
|
||||
|
||||
type ExampleService interface {
|
||||
Method1(ctx context.Context, req *Method1Request) (*Method1Response, error)
|
||||
Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error)
|
||||
}
|
||||
|
||||
func RegisterExampleService(srv *github_com_stevvooe_ttrpc.Server, svc ExampleService) error {
|
||||
return srv.Register("ttrpc.example.v1.Example", map[string]github_com_stevvooe_ttrpc.Handler{
|
||||
"Method1": github_com_stevvooe_ttrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return svc.Method1(ctx, req.(*Method1Request))
|
||||
}),
|
||||
"Method2": github_com_stevvooe_ttrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return svc.Method2(ctx, req.(*Method1Request))
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
type ExampleClient struct {
|
||||
client *github_com_stevvooe_ttrpc.Client
|
||||
}
|
||||
|
||||
func (c *ExampleClient) Method1(ctx context.Context, req *Method1Request) (*Method1Response, error) {
|
||||
resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method1", req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*Method1Response), nil
|
||||
}
|
||||
|
||||
func (c *ExampleClient) Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error) {
|
||||
resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method2", req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*google_protobuf1.Empty), nil
|
||||
}
|
||||
func (m *Method1Request) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
@ -310,6 +274,48 @@ func valueToStringExample(v interface{}) string {
|
||||
pv := reflect.Indirect(rv).Interface()
|
||||
return fmt.Sprintf("*%v", pv)
|
||||
}
|
||||
|
||||
type ExampleService interface {
|
||||
Method1(ctx context.Context, req *Method1Request) (*Method1Response, error)
|
||||
Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error)
|
||||
}
|
||||
|
||||
func RegisterExampleService(srv *github_com_stevvooe_ttrpc.Server, svc ExampleService) error {
|
||||
return srv.Register("ttrpc.example.v1.Example", map[string]github_com_stevvooe_ttrpc.Handler{
|
||||
"Method1": github_com_stevvooe_ttrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return svc.Method1(ctx, req.(*Method1Request))
|
||||
}),
|
||||
"Method2": github_com_stevvooe_ttrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return svc.Method2(ctx, req.(*Method1Request))
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
type exampleClient struct {
|
||||
client *github_com_stevvooe_ttrpc.Client
|
||||
}
|
||||
|
||||
func NewExampleClient(client *github_com_stevvooe_ttrpc.Client) ExampleService {
|
||||
return &exampleClient{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *exampleClient) Method1(ctx context.Context, req *Method1Request) (*Method1Response, error) {
|
||||
resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method1", req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*Method1Response), nil
|
||||
}
|
||||
|
||||
func (c *exampleClient) Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error) {
|
||||
resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method2", req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*google_protobuf1.Empty), nil
|
||||
}
|
||||
func (m *Method1Request) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
@ -718,21 +724,21 @@ var fileDescriptorExample = []byte{
|
||||
// 297 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xb1, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0xad, 0x41, 0x6a, 0x85, 0x07, 0xa8, 0x22, 0x54, 0x95, 0x20, 0x99, 0xd2, 0xa9, 0x2c, 0xb6,
|
||||
0x1a, 0x60, 0x62, 0xa3, 0xea, 0x08, 0x43, 0x47, 0x36, 0x27, 0xb8, 0x6e, 0xa4, 0x3a, 0x67, 0x12,
|
||||
0x27, 0x82, 0x8d, 0x2f, 0xe1, 0x7b, 0x3a, 0x32, 0x32, 0xd2, 0x7c, 0x09, 0x4a, 0x62, 0x23, 0x91,
|
||||
0x81, 0x76, 0xba, 0xf3, 0x7b, 0xf7, 0xee, 0x9d, 0x9e, 0x8c, 0x99, 0x8c, 0xcd, 0x2a, 0x0f, 0x69,
|
||||
0x04, 0x8a, 0x65, 0x46, 0x14, 0x05, 0x80, 0x60, 0x4a, 0xa6, 0x3a, 0x62, 0xe2, 0x95, 0x2b, 0xbd,
|
||||
0x16, 0xae, 0x52, 0x9d, 0x82, 0x01, 0xaf, 0x5f, 0x93, 0xd4, 0x81, 0xc5, 0xd4, 0x3f, 0x93, 0x00,
|
||||
0x72, 0x2d, 0x58, 0xcd, 0x87, 0xf9, 0x92, 0xf1, 0xe4, 0xad, 0x19, 0xf6, 0xcf, 0xdb, 0x94, 0x50,
|
||||
0xda, 0x38, 0xf2, 0x54, 0x82, 0x84, 0xba, 0x65, 0x55, 0x67, 0xd1, 0x8b, 0xb6, 0xc4, 0xc4, 0x4a,
|
||||
0x64, 0x86, 0x2b, 0xdd, 0x0c, 0x8c, 0x6f, 0xf0, 0xf1, 0x83, 0x30, 0x2b, 0x78, 0x9e, 0x2e, 0xc4,
|
||||
0x4b, 0x2e, 0x32, 0xe3, 0xf5, 0xf1, 0xe1, 0x12, 0x60, 0x88, 0x46, 0x68, 0x72, 0xb4, 0xa8, 0xda,
|
||||
0x0a, 0x09, 0x79, 0x3a, 0x3c, 0x68, 0x90, 0x90, 0xa7, 0xe3, 0x5b, 0x7c, 0xf2, 0xab, 0xca, 0x34,
|
||||
0x24, 0x99, 0xd8, 0x4b, 0x36, 0x71, 0x66, 0x81, 0x33, 0x1b, 0xe0, 0x2e, 0x8f, 0x4c, 0x0c, 0x89,
|
||||
0x15, 0xda, 0x57, 0xf0, 0x81, 0x70, 0x6f, 0xde, 0x84, 0xe2, 0x3d, 0xe2, 0x9e, 0x35, 0xf3, 0x46,
|
||||
0xb4, 0x9d, 0x17, 0xfd, 0x7b, 0xbd, 0x7f, 0xf9, 0xcf, 0x84, 0xbd, 0x74, 0xe6, 0xf6, 0x05, 0x7b,
|
||||
0xec, 0x1b, 0xd0, 0x26, 0x41, 0xea, 0x12, 0xa4, 0xf3, 0x2a, 0xf4, 0xfb, 0xd9, 0x66, 0x4b, 0x3a,
|
||||
0x5f, 0x5b, 0xd2, 0x79, 0x2f, 0x09, 0xda, 0x94, 0x04, 0x7d, 0x96, 0x04, 0x7d, 0x97, 0x04, 0x3d,
|
||||
0x5d, 0xed, 0xfc, 0x03, 0x77, 0xb6, 0x86, 0xdd, 0x7a, 0xe9, 0xf5, 0x4f, 0x00, 0x00, 0x00, 0xff,
|
||||
0xff, 0x69, 0x3f, 0x4b, 0x81, 0x37, 0x02, 0x00, 0x00,
|
||||
0x1a, 0x60, 0x62, 0xa3, 0xea, 0x08, 0x43, 0x47, 0x36, 0x27, 0xb8, 0x69, 0xa4, 0x26, 0x67, 0x92,
|
||||
0x4b, 0x04, 0x1b, 0x5f, 0xc2, 0xf7, 0x74, 0x64, 0x64, 0xa4, 0xf9, 0x12, 0x94, 0xc4, 0x46, 0x22,
|
||||
0x03, 0xed, 0x74, 0xe7, 0xf7, 0xee, 0xdd, 0x3b, 0x3d, 0x99, 0x8a, 0x30, 0xc2, 0x55, 0xee, 0xf3,
|
||||
0x00, 0x62, 0x91, 0xa1, 0x2a, 0x0a, 0x00, 0x25, 0x10, 0x53, 0x1d, 0x08, 0xf5, 0x2a, 0x63, 0xbd,
|
||||
0x56, 0xb6, 0x72, 0x9d, 0x02, 0x82, 0xd3, 0xaf, 0x49, 0x6e, 0xc1, 0x62, 0xea, 0x9e, 0x85, 0x00,
|
||||
0xe1, 0x5a, 0x89, 0x9a, 0xf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0x89, 0xbc, 0x37, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package mgrpc.example.v1;
|
||||
package ttrpc.example.v1;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/stevvooe/mgrpc/example;example";
|
||||
option go_package = "github.com/stevvooe/ttrpc/example;example";
|
||||
|
||||
service Example {
|
||||
rpc Method1(Method1Request) returns (Method1Response);
|
||||
|
Loading…
Reference in New Issue
Block a user