parent
96883fc81e
commit
be90e1b988
@ -0,0 +1,5 @@
|
||||
#!/bin/bash -x
|
||||
#
|
||||
cd $(dirname $0)
|
||||
protoc --go_out=plugins=grpc:. *.proto
|
||||
go install
|
@ -0,0 +1,183 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: gosuv.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package gosuvpb is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
gosuv.proto
|
||||
|
||||
It has these top-level messages:
|
||||
CtrlRequest
|
||||
CtrlResponse
|
||||
NopRequest
|
||||
Response
|
||||
*/
|
||||
package gosuvpb
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type CtrlRequest struct {
|
||||
Action *string `protobuf:"bytes,1,req,name=action" json:"action,omitempty"`
|
||||
Name *string `protobuf:"bytes,2,req,name=name" json:"name,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CtrlRequest) Reset() { *m = CtrlRequest{} }
|
||||
func (m *CtrlRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CtrlRequest) ProtoMessage() {}
|
||||
|
||||
func (m *CtrlRequest) GetAction() string {
|
||||
if m != nil && m.Action != nil {
|
||||
return *m.Action
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CtrlRequest) GetName() string {
|
||||
if m != nil && m.Name != nil {
|
||||
return *m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CtrlResponse struct {
|
||||
Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CtrlResponse) Reset() { *m = CtrlResponse{} }
|
||||
func (m *CtrlResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CtrlResponse) ProtoMessage() {}
|
||||
|
||||
func (m *CtrlResponse) GetValue() string {
|
||||
if m != nil && m.Value != nil {
|
||||
return *m.Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NopRequest struct {
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *NopRequest) Reset() { *m = NopRequest{} }
|
||||
func (m *NopRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*NopRequest) ProtoMessage() {}
|
||||
|
||||
type Response struct {
|
||||
Code *int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*Response) ProtoMessage() {}
|
||||
|
||||
func (m *Response) GetCode() int32 {
|
||||
if m != nil && m.Code != nil {
|
||||
return *m.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// Client API for GoSuv service
|
||||
|
||||
type GoSuvClient interface {
|
||||
Control(ctx context.Context, in *CtrlRequest, opts ...grpc.CallOption) (*CtrlResponse, error)
|
||||
Shutdown(ctx context.Context, in *NopRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
}
|
||||
|
||||
type goSuvClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewGoSuvClient(cc *grpc.ClientConn) GoSuvClient {
|
||||
return &goSuvClient{cc}
|
||||
}
|
||||
|
||||
func (c *goSuvClient) Control(ctx context.Context, in *CtrlRequest, opts ...grpc.CallOption) (*CtrlResponse, error) {
|
||||
out := new(CtrlResponse)
|
||||
err := grpc.Invoke(ctx, "/gosuvpb.GoSuv/Control", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *goSuvClient) Shutdown(ctx context.Context, in *NopRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
out := new(Response)
|
||||
err := grpc.Invoke(ctx, "/gosuvpb.GoSuv/Shutdown", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for GoSuv service
|
||||
|
||||
type GoSuvServer interface {
|
||||
Control(context.Context, *CtrlRequest) (*CtrlResponse, error)
|
||||
Shutdown(context.Context, *NopRequest) (*Response, error)
|
||||
}
|
||||
|
||||
func RegisterGoSuvServer(s *grpc.Server, srv GoSuvServer) {
|
||||
s.RegisterService(&_GoSuv_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _GoSuv_Control_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) {
|
||||
in := new(CtrlRequest)
|
||||
if err := codec.Unmarshal(buf, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := srv.(GoSuvServer).Control(ctx, in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func _GoSuv_Shutdown_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) {
|
||||
in := new(NopRequest)
|
||||
if err := codec.Unmarshal(buf, in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := srv.(GoSuvServer).Shutdown(ctx, in)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
var _GoSuv_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "gosuvpb.GoSuv",
|
||||
HandlerType: (*GoSuvServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Control",
|
||||
Handler: _GoSuv_Control_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Shutdown",
|
||||
Handler: _GoSuv_Shutdown_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package gosuvpb;
|
||||
|
||||
message CtrlRequest {
|
||||
required string action =1;
|
||||
required string name = 2;
|
||||
}
|
||||
|
||||
message CtrlResponse {
|
||||
optional string value = 1;
|
||||
}
|
||||
|
||||
message NopRequest {
|
||||
}
|
||||
|
||||
message Response {
|
||||
optional int32 code = 1;
|
||||
}
|
||||
|
||||
service GoSuv {
|
||||
rpc Control(CtrlRequest) returns (CtrlResponse) {};
|
||||
rpc Shutdown(NopRequest) returns (Response) {};
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: gosuv.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package pbrpc is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
gosuv.proto
|
||||
|
||||
It has these top-level messages:
|
||||
CtrlRequest
|
||||
CtrlResponse
|
||||
*/
|
||||
package pbrpc
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type CtrlRequest struct {
|
||||
Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"`
|
||||
Key *string `protobuf:"bytes,2,req,name=key" json:"key,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CtrlRequest) Reset() { *m = CtrlRequest{} }
|
||||
func (m *CtrlRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*CtrlRequest) ProtoMessage() {}
|
||||
|
||||
func (m *CtrlRequest) GetName() string {
|
||||
if m != nil && m.Name != nil {
|
||||
return *m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CtrlRequest) GetKey() string {
|
||||
if m != nil && m.Key != nil {
|
||||
return *m.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CtrlResponse struct {
|
||||
Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CtrlResponse) Reset() { *m = CtrlResponse{} }
|
||||
func (m *CtrlResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*CtrlResponse) ProtoMessage() {}
|
||||
|
||||
func (m *CtrlResponse) GetValue() string {
|
||||
if m != nil && m.Value != nil {
|
||||
return *m.Value
|
||||
}
|
||||
return ""
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package pbrpc;
|
||||
|
||||
message CtrlRequest {
|
||||
required string name = 1;
|
||||
required string key = 2; // not actually required/guaranteed to be UTF-8
|
||||
}
|
||||
|
||||
message CtrlResponse {
|
||||
optional string value = 1;
|
||||
}
|
||||
|
||||
service GoSUV{
|
||||
rpc Control(CtrlRequest) returns (CtrlResponse) {
|
||||
};
|
||||
}
|
Loading…
Reference in new issue