From f147d6ca77fd70cb8bb4be901e491e8eb8a0b151 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Wed, 15 Nov 2017 17:04:16 -0800 Subject: [PATCH] ttrpc: rename project to ttrpc Signed-off-by: Stephen J Day --- channel.go | 2 +- channel_test.go | 2 +- client.go | 2 +- cmd/protoc-gen-gogomgrpc/main.go | 2 +- example/example.pb.go | 28 +++++++++++++------------- generator.go | 34 ++++++++++++++++---------------- handlers.go | 2 +- server.go | 2 +- server_test.go | 2 +- types.go | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/channel.go b/channel.go index d4ef6bb..2339767 100644 --- a/channel.go +++ b/channel.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "bufio" diff --git a/channel_test.go b/channel_test.go index 12b9e92..8bff326 100644 --- a/channel_test.go +++ b/channel_test.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "bufio" diff --git a/client.go b/client.go index 6efd7e9..2fdd638 100644 --- a/client.go +++ b/client.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "context" diff --git a/cmd/protoc-gen-gogomgrpc/main.go b/cmd/protoc-gen-gogomgrpc/main.go index 0d1c854..7016202 100644 --- a/cmd/protoc-gen-gogomgrpc/main.go +++ b/cmd/protoc-gen-gogomgrpc/main.go @@ -4,7 +4,7 @@ import ( "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" "github.com/gogo/protobuf/vanity" "github.com/gogo/protobuf/vanity/command" - _ "github.com/stevvooe/mgrpc" + _ "github.com/stevvooe/ttrpc" ) func main() { diff --git a/example/example.pb.go b/example/example.pb.go index d6862d9..2235287 100644 --- a/example/example.pb.go +++ b/example/example.pb.go @@ -1,11 +1,11 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: github.com/stevvooe/mgrpc/example/example.proto +// source: github.com/stevvooe/ttrpc/example/example.proto /* Package example is a generated protocol buffer package. It is generated from these files: - github.com/stevvooe/mgrpc/example/example.proto + github.com/stevvooe/ttrpc/example/example.proto It has these top-level messages: Method1Request @@ -23,7 +23,7 @@ import _ "github.com/gogo/protobuf/gogoproto" import _ "github.com/gogo/protobuf/types" import context "context" -import github_com_stevvooe_mgrpc "github.com/stevvooe/mgrpc" +import github_com_stevvooe_ttrpc "github.com/stevvooe/ttrpc" import strings "strings" import reflect "reflect" @@ -68,9 +68,9 @@ func (*Method2Request) ProtoMessage() {} func (*Method2Request) Descriptor() ([]byte, []int) { return fileDescriptorExample, []int{2} } func init() { - proto.RegisterType((*Method1Request)(nil), "mgrpc.example.v1.Method1Request") - proto.RegisterType((*Method1Response)(nil), "mgrpc.example.v1.Method1Response") - proto.RegisterType((*Method2Request)(nil), "mgrpc.example.v1.Method2Request") + proto.RegisterType((*Method1Request)(nil), "ttrpc.example.v1.Method1Request") + proto.RegisterType((*Method1Response)(nil), "ttrpc.example.v1.Method1Response") + proto.RegisterType((*Method2Request)(nil), "ttrpc.example.v1.Method2Request") } func (m *Method1Request) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -189,23 +189,23 @@ type ExampleService interface { Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error) } -func RegisterExampleService(srv *github_com_stevvooe_mgrpc.Server, svc ExampleService) error { - return srv.Register("mgrpc.example.v1.Example", map[string]github_com_stevvooe_mgrpc.Handler{ - "Method1": github_com_stevvooe_mgrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, 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_mgrpc.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) { + "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_mgrpc.Client + client *github_com_stevvooe_ttrpc.Client } func (c *ExampleClient) Method1(ctx context.Context, req *Method1Request) (*Method1Response, error) { - resp, err := c.client.Call(ctx, "mgrpc.example.v1.Example", "Method1", req) + resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method1", req) if err != nil { return nil, err } @@ -213,7 +213,7 @@ func (c *ExampleClient) Method1(ctx context.Context, req *Method1Request) (*Meth } func (c *ExampleClient) Method2(ctx context.Context, req *Method1Request) (*google_protobuf1.Empty, error) { - resp, err := c.client.Call(ctx, "mgrpc.example.v1.Example", "Method2", req) + resp, err := c.client.Call(ctx, "ttrpc.example.v1.Example", "Method2", req) if err != nil { return nil, err } @@ -711,7 +711,7 @@ var ( ) func init() { - proto.RegisterFile("github.com/stevvooe/mgrpc/example/example.proto", fileDescriptorExample) + proto.RegisterFile("github.com/stevvooe/ttrpc/example/example.proto", fileDescriptorExample) } var fileDescriptorExample = []byte{ diff --git a/generator.go b/generator.go index 633ff0f..b27f47a 100644 --- a/generator.go +++ b/generator.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "strings" @@ -7,32 +7,32 @@ import ( "github.com/gogo/protobuf/protoc-gen-gogo/generator" ) -type mgrpcGenerator struct { +type ttrpcGenerator struct { *generator.Generator generator.PluginImports typeurlPkg generator.Single - mgrpcPkg generator.Single + ttrpcPkg generator.Single contextPkg generator.Single } func init() { - generator.RegisterPlugin(new(mgrpcGenerator)) + generator.RegisterPlugin(new(ttrpcGenerator)) } -func (p *mgrpcGenerator) Name() string { - return "mgrpc" +func (p *ttrpcGenerator) Name() string { + return "ttrpc" } -func (p *mgrpcGenerator) Init(g *generator.Generator) { +func (p *ttrpcGenerator) Init(g *generator.Generator) { p.Generator = g } -func (p *mgrpcGenerator) Generate(file *generator.FileDescriptor) { +func (p *ttrpcGenerator) Generate(file *generator.FileDescriptor) { p.PluginImports = generator.NewPluginImports(p.Generator) p.contextPkg = p.NewImport("context") p.typeurlPkg = p.NewImport("github.com/containerd/typeurl") - p.mgrpcPkg = p.NewImport("github.com/stevvooe/mgrpc") + p.ttrpcPkg = p.NewImport("github.com/stevvooe/ttrpc") for _, service := range file.GetService() { serviceName := service.GetName() @@ -44,7 +44,7 @@ func (p *mgrpcGenerator) Generate(file *generator.FileDescriptor) { } } -func (p *mgrpcGenerator) genService(fullName string, service *descriptor.ServiceDescriptorProto) { +func (p *ttrpcGenerator) genService(fullName string, service *descriptor.ServiceDescriptorProto) { serviceName := service.GetName() + "Service" p.P() p.P("type ", serviceName, " interface{") @@ -61,12 +61,12 @@ func (p *mgrpcGenerator) genService(fullName string, service *descriptor.Service p.P() // registration method - p.P("func Register", serviceName, "(srv *", p.mgrpcPkg.Use(), ".Server, svc ", serviceName, ") error {") + p.P("func Register", serviceName, "(srv *", p.ttrpcPkg.Use(), ".Server, svc ", serviceName, ") error {") p.In() - p.P(`return srv.Register("`, fullName, `", map[string]`, p.mgrpcPkg.Use(), ".Handler{") + p.P(`return srv.Register("`, fullName, `", map[string]`, p.ttrpcPkg.Use(), ".Handler{") p.In() for _, method := range service.Method { - p.P(`"`, method.GetName(), `": `, p.mgrpcPkg.Use(), `.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {`) + p.P(`"`, method.GetName(), `": `, p.ttrpcPkg.Use(), `.HandlerFunc(func(ctx context.Context, req interface{}) (interface{}, error) {`) p.In() p.P("return svc.", method.GetName(), "(ctx, req.(*", p.typeName(method.GetInputType()), "))") p.Out() @@ -82,11 +82,11 @@ func (p *mgrpcGenerator) genService(fullName string, service *descriptor.Service p.P() p.P("type ", clientStructType, " struct{") p.In() - p.P("client *", p.mgrpcPkg.Use(), ".Client") + p.P("client *", p.ttrpcPkg.Use(), ".Client") p.Out() p.P("}") p.P() - p.P("func New", clientType, "(client *", p.mgrpcPkg.Use(), ".Client)", serviceName, "{") + p.P("func New", clientType, "(client *", p.ttrpcPkg.Use(), ".Client)", serviceName, "{") p.In() p.P("return &", clientStructType, "{") p.In() @@ -115,11 +115,11 @@ func (p *mgrpcGenerator) genService(fullName string, service *descriptor.Service } } -func (p *mgrpcGenerator) objectNamed(name string) generator.Object { +func (p *ttrpcGenerator) objectNamed(name string) generator.Object { p.Generator.RecordTypeUse(name) return p.Generator.ObjectNamed(name) } -func (p *mgrpcGenerator) typeName(str string) string { +func (p *ttrpcGenerator) typeName(str string) string { return p.Generator.TypeName(p.objectNamed(str)) } diff --git a/handlers.go b/handlers.go index c34fec4..cdc7b71 100644 --- a/handlers.go +++ b/handlers.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import "context" diff --git a/server.go b/server.go index 3cec9b8..f0e3f1d 100644 --- a/server.go +++ b/server.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "context" diff --git a/server_test.go b/server_test.go index 0406f71..ebed3f7 100644 --- a/server_test.go +++ b/server_test.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "context" diff --git a/types.go b/types.go index fc78a3c..681da30 100644 --- a/types.go +++ b/types.go @@ -1,4 +1,4 @@ -package mgrpc +package ttrpc import ( "fmt"