ttrpc: rename project to ttrpc

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2017-11-15 17:04:16 -08:00
parent 1bfe6fb8f6
commit f147d6ca77
No known key found for this signature in database
GPG Key ID: 67B3DED84EDC823F
10 changed files with 39 additions and 39 deletions

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"bufio"

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"bufio"

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"context"

View File

@ -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() {

View File

@ -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{

View File

@ -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))
}

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import "context"

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"context"

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"context"

View File

@ -1,4 +1,4 @@
package mgrpc
package ttrpc
import (
"fmt"