зеркало из https://github.com/github/vitess-gh.git
Re-organizing protos.
Moving the protos to proto/ Adding a Makefile rule to re-generate the go files from them (assuming protoc is in the path). Moving the generated files to directories where the package name matches the directory name, always easier that way.
This commit is contained in:
Родитель
2d953d8bb9
Коммит
ed178436a0
11
Makefile
11
Makefile
|
@ -4,7 +4,7 @@
|
|||
|
||||
MAKEFLAGS = -s
|
||||
|
||||
.PHONY: all build test clean unit_test unit_test_cover unit_test_race queryservice_test integration_test bson site_test site_integration_test
|
||||
.PHONY: all build test clean unit_test unit_test_cover unit_test_race queryservice_test integration_test bson proto site_test site_integration_test
|
||||
|
||||
all: build test
|
||||
|
||||
|
@ -171,3 +171,12 @@ v3_test:
|
|||
|
||||
bson:
|
||||
go generate ./go/...
|
||||
|
||||
# This rule rebuilds all the go files from the proto definitions for gRPC
|
||||
# It requires protoc in the path (that supports proto3, with grpc plug-in)
|
||||
# Get protoc from: https://github.com/google/protobuf/blob/master/INSTALL.txt
|
||||
# And get grpc plug-in with: go get -a github.com/golang/protobuf/protoc-gen-go
|
||||
proto:
|
||||
cd go/vt/proto/vtctl && protoc -I../../../../proto ../../../../proto/vtctl.proto --go_out=plugins=grpc:.
|
||||
cd go/vt/proto/tabletmanager && protoc -I../../../../proto ../../../../proto/tabletmanager.proto --go_out=plugins=grpc:.
|
||||
find go/vt/proto -name "*.pb.go" | xargs sed --in-place -r -e 's,"([a-z0-9_]+).pb","github.com/youtube/vitess/go/vt/proto/\1",g'
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
// Code generated by protoc-gen-go.
|
||||
// source: tabletmanager.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package tabletmanager is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
tabletmanager.proto
|
||||
|
||||
It has these top-level messages:
|
||||
SnapshotArgs
|
||||
*/
|
||||
package tabletmanager
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import vtctl "github.com/youtube/vitess/go/vt/proto/vtctl"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
|
||||
type SnapshotArgs struct {
|
||||
Concurrency int64 `protobuf:"varint,1,opt,name=concurrency" json:"concurrency,omitempty"`
|
||||
ServerMode bool `protobuf:"varint,2,opt,name=server_mode" json:"server_mode,omitempty"`
|
||||
ForceMasterSnapshot bool `protobuf:"varint,3,opt,name=force_master_snapshot" json:"force_master_snapshot,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SnapshotArgs) Reset() { *m = SnapshotArgs{} }
|
||||
func (m *SnapshotArgs) String() string { return proto.CompactTextString(m) }
|
||||
func (*SnapshotArgs) ProtoMessage() {}
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
// Client API for TabletManager service
|
||||
|
||||
type TabletManagerClient interface {
|
||||
// FIXME(alainjobart) need to also return SnapshotReply
|
||||
Snapshot(ctx context.Context, in *SnapshotArgs, opts ...grpc.CallOption) (TabletManager_SnapshotClient, error)
|
||||
}
|
||||
|
||||
type tabletManagerClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewTabletManagerClient(cc *grpc.ClientConn) TabletManagerClient {
|
||||
return &tabletManagerClient{cc}
|
||||
}
|
||||
|
||||
func (c *tabletManagerClient) Snapshot(ctx context.Context, in *SnapshotArgs, opts ...grpc.CallOption) (TabletManager_SnapshotClient, error) {
|
||||
stream, err := grpc.NewClientStream(ctx, &_TabletManager_serviceDesc.Streams[0], c.cc, "/tabletmanager.TabletManager/Snapshot", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &tabletManagerSnapshotClient{stream}
|
||||
if err := x.ClientStream.SendProto(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type TabletManager_SnapshotClient interface {
|
||||
Recv() (*vtctl.LoggerEvent, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type tabletManagerSnapshotClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *tabletManagerSnapshotClient) Recv() (*vtctl.LoggerEvent, error) {
|
||||
m := new(vtctl.LoggerEvent)
|
||||
if err := x.ClientStream.RecvProto(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Server API for TabletManager service
|
||||
|
||||
type TabletManagerServer interface {
|
||||
// FIXME(alainjobart) need to also return SnapshotReply
|
||||
Snapshot(*SnapshotArgs, TabletManager_SnapshotServer) error
|
||||
}
|
||||
|
||||
func RegisterTabletManagerServer(s *grpc.Server, srv TabletManagerServer) {
|
||||
s.RegisterService(&_TabletManager_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _TabletManager_Snapshot_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(SnapshotArgs)
|
||||
if err := stream.RecvProto(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(TabletManagerServer).Snapshot(m, &tabletManagerSnapshotServer{stream})
|
||||
}
|
||||
|
||||
type TabletManager_SnapshotServer interface {
|
||||
Send(*vtctl.LoggerEvent) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type tabletManagerSnapshotServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *tabletManagerSnapshotServer) Send(m *vtctl.LoggerEvent) error {
|
||||
return x.ServerStream.SendProto(m)
|
||||
}
|
||||
|
||||
var _TabletManager_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "tabletmanager.TabletManager",
|
||||
HandlerType: (*TabletManagerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Snapshot",
|
||||
Handler: _TabletManager_Snapshot_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
}
|
|
@ -14,7 +14,7 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "github.com/youtube/vitess/go/vt/vtctl/grpcproto"
|
||||
pb "github.com/youtube/vitess/go/vt/proto/vtctl"
|
||||
)
|
||||
|
||||
type gRPCVtctlClient struct {
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/youtube/vitess/go/vt/vtctl/vtctlclienttest"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "github.com/youtube/vitess/go/vt/vtctl/grpcproto"
|
||||
pb "github.com/youtube/vitess/go/vt/proto/vtctl"
|
||||
)
|
||||
|
||||
// the test here creates a fake server implementation, a fake client
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
"github.com/youtube/vitess/go/vt/topo"
|
||||
"github.com/youtube/vitess/go/vt/wrangler"
|
||||
|
||||
pb "github.com/youtube/vitess/go/vt/proto/vtctl"
|
||||
"github.com/youtube/vitess/go/vt/vtctl"
|
||||
pb "github.com/youtube/vitess/go/vt/vtctl/grpcproto"
|
||||
)
|
||||
|
||||
// VtctlServer is our RPC server
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// This file contains all the types and servers necessary to make
|
||||
// gRPC calls to Vttablet for the management API.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package tabletmanager;
|
||||
|
||||
import "vtctl.proto";
|
||||
|
||||
message SnapshotArgs {
|
||||
optional int64 concurrency = 1;
|
||||
optional bool server_mode = 2;
|
||||
optional bool force_master_snapshot = 3;
|
||||
}
|
||||
|
||||
service TabletManager {
|
||||
// FIXME(alainjobart) need to also return SnapshotReply
|
||||
rpc Snapshot(SnapshotArgs) returns (stream vtctl.LoggerEvent) {};
|
||||
}
|
|
@ -1,13 +1,3 @@
|
|||
// FIXME(alainjobart): I had to compile protoc from:
|
||||
// https://github.com/google/protobuf/blob/master/INSTALL.txt
|
||||
// and then run:
|
||||
// protoc vtctl.proto --go_out=plugins=grpc:.
|
||||
// to generate this file. We need to streamline this.
|
||||
//
|
||||
// (this is in addition to running:
|
||||
// go get -a github.com/golang/protobuf/protoc-gen-go
|
||||
// but that is in bootstrap.sh)
|
||||
|
||||
// This package contains a service allowing you to use vtctld as a
|
||||
// proxy for vt commands.
|
||||
syntax = "proto3";
|
Загрузка…
Ссылка в новой задаче