|
|
@ -0,0 +1,221 @@ |
|
|
|
// Code generated by protoc-gen-go.
|
|
|
|
// source: supplier.proto
|
|
|
|
// DO NOT EDIT!
|
|
|
|
|
|
|
|
/* |
|
|
|
Package supplierrpc is a generated protocol buffer package. |
|
|
|
|
|
|
|
It is generated from these files: |
|
|
|
supplier.proto |
|
|
|
|
|
|
|
It has these top-level messages: |
|
|
|
GetRequest |
|
|
|
GetUuidRequest |
|
|
|
GetResponse |
|
|
|
BoolResponse |
|
|
|
*/ |
|
|
|
package supplierrpc |
|
|
|
|
|
|
|
import proto "github.com/chai2010/protorpc/proto" |
|
|
|
import math "math" |
|
|
|
|
|
|
|
import "io" |
|
|
|
import "log" |
|
|
|
import "net" |
|
|
|
import "net/rpc" |
|
|
|
import "time" |
|
|
|
import protorpc "github.com/chai2010/protorpc" |
|
|
|
|
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
|
var _ = proto.Marshal |
|
|
|
var _ = math.Inf |
|
|
|
|
|
|
|
// 使用key查询
|
|
|
|
type GetRequest struct { |
|
|
|
Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"` |
|
|
|
Id *string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` |
|
|
|
XXX_unrecognized []byte `json:"-"` |
|
|
|
} |
|
|
|
|
|
|
|
func (m *GetRequest) Reset() { *m = GetRequest{} } |
|
|
|
func (m *GetRequest) String() string { return proto.CompactTextString(m) } |
|
|
|
func (*GetRequest) ProtoMessage() {} |
|
|
|
|
|
|
|
func (m *GetRequest) GetDbname() string { |
|
|
|
if m != nil && m.Dbname != nil { |
|
|
|
return *m.Dbname |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
func (m *GetRequest) GetId() string { |
|
|
|
if m != nil && m.Id != nil { |
|
|
|
return *m.Id |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
type GetUuidRequest struct { |
|
|
|
Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"` |
|
|
|
Uuid *string `protobuf:"bytes,2,opt,name=uuid" json:"uuid,omitempty"` |
|
|
|
XXX_unrecognized []byte `json:"-"` |
|
|
|
} |
|
|
|
|
|
|
|
func (m *GetUuidRequest) Reset() { *m = GetUuidRequest{} } |
|
|
|
func (m *GetUuidRequest) String() string { return proto.CompactTextString(m) } |
|
|
|
func (*GetUuidRequest) ProtoMessage() {} |
|
|
|
|
|
|
|
func (m *GetUuidRequest) GetDbname() string { |
|
|
|
if m != nil && m.Dbname != nil { |
|
|
|
return *m.Dbname |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
func (m *GetUuidRequest) GetUuid() string { |
|
|
|
if m != nil && m.Uuid != nil { |
|
|
|
return *m.Uuid |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
// 使用key查询响应结构
|
|
|
|
type GetResponse struct { |
|
|
|
Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` |
|
|
|
XXX_unrecognized []byte `json:"-"` |
|
|
|
} |
|
|
|
|
|
|
|
func (m *GetResponse) Reset() { *m = GetResponse{} } |
|
|
|
func (m *GetResponse) String() string { return proto.CompactTextString(m) } |
|
|
|
func (*GetResponse) ProtoMessage() {} |
|
|
|
|
|
|
|
func (m *GetResponse) GetValue() []byte { |
|
|
|
if m != nil { |
|
|
|
return m.Value |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
// 使用key查询响应结构
|
|
|
|
type BoolResponse struct { |
|
|
|
Value *bool `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` |
|
|
|
XXX_unrecognized []byte `json:"-"` |
|
|
|
} |
|
|
|
|
|
|
|
func (m *BoolResponse) Reset() { *m = BoolResponse{} } |
|
|
|
func (m *BoolResponse) String() string { return proto.CompactTextString(m) } |
|
|
|
func (*BoolResponse) ProtoMessage() {} |
|
|
|
|
|
|
|
func (m *BoolResponse) GetValue() bool { |
|
|
|
if m != nil && m.Value != nil { |
|
|
|
return *m.Value |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
func init() { |
|
|
|
} |
|
|
|
|
|
|
|
type ProductService interface { |
|
|
|
Get(in *GetRequest, out *GetResponse) error |
|
|
|
GetByUuid(in *GetUuidRequest, out *GetResponse) error |
|
|
|
IsOpen(in *GetRequest, out *BoolResponse) error |
|
|
|
} |
|
|
|
|
|
|
|
// AcceptProductServiceClient accepts connections on the listener and serves requests
|
|
|
|
// for each incoming connection. Accept blocks; the caller typically
|
|
|
|
// invokes it in a go statement.
|
|
|
|
func AcceptProductServiceClient(lis net.Listener, x ProductService) { |
|
|
|
srv := rpc.NewServer() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
} |
|
|
|
|
|
|
|
for { |
|
|
|
conn, err := lis.Accept() |
|
|
|
if err != nil { |
|
|
|
log.Fatalf("lis.Accept(): %v\n", err) |
|
|
|
} |
|
|
|
go srv.ServeCodec(protorpc.NewServerCodec(conn)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// RegisterProductService publish the given ProductService implementation on the server.
|
|
|
|
func RegisterProductService(srv *rpc.Server, x ProductService) error { |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
// NewProductServiceServer returns a new ProductService Server.
|
|
|
|
func NewProductServiceServer(x ProductService) *rpc.Server { |
|
|
|
srv := rpc.NewServer() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
} |
|
|
|
return srv |
|
|
|
} |
|
|
|
|
|
|
|
// ListenAndServeProductService listen announces on the local network address laddr
|
|
|
|
// and serves the given ProductService implementation.
|
|
|
|
func ListenAndServeProductService(network, addr string, x ProductService) error { |
|
|
|
lis, err := net.Listen(network, addr) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
defer lis.Close() |
|
|
|
|
|
|
|
srv := rpc.NewServer() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
for { |
|
|
|
conn, err := lis.Accept() |
|
|
|
if err != nil { |
|
|
|
log.Fatalf("lis.Accept(): %v\n", err) |
|
|
|
} |
|
|
|
go srv.ServeCodec(protorpc.NewServerCodec(conn)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type ProductServiceClient struct { |
|
|
|
*rpc.Client |
|
|
|
} |
|
|
|
|
|
|
|
// NewProductServiceClient returns a ProductService rpc.Client and stub to handle
|
|
|
|
// requests to the set of ProductService at the other end of the connection.
|
|
|
|
func NewProductServiceClient(conn io.ReadWriteCloser) (*ProductServiceClient, *rpc.Client) { |
|
|
|
c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn)) |
|
|
|
return &ProductServiceClient{c}, c |
|
|
|
} |
|
|
|
|
|
|
|
func (c *ProductServiceClient) Get(in *GetRequest, out *GetResponse) error { |
|
|
|
return c.Call("ProductService.Get", in, out) |
|
|
|
} |
|
|
|
func (c *ProductServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error { |
|
|
|
return c.Call("ProductService.GetByUuid", in, out) |
|
|
|
} |
|
|
|
func (c *ProductServiceClient) IsOpen(in *GetRequest, out *BoolResponse) error { |
|
|
|
return c.Call("ProductService.IsOpen", in, out) |
|
|
|
} |
|
|
|
|
|
|
|
// DialProductService connects to an ProductService at the specified network address.
|
|
|
|
func DialProductService(network, addr string) (*ProductServiceClient, *rpc.Client, error) { |
|
|
|
c, err := protorpc.Dial(network, addr) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
return &ProductServiceClient{c}, c, nil |
|
|
|
} |
|
|
|
|
|
|
|
// DialProductServiceTimeout connects to an ProductService at the specified network address.
|
|
|
|
func DialProductServiceTimeout(network, addr string, |
|
|
|
timeout time.Duration) (*ProductServiceClient, *rpc.Client, error) { |
|
|
|
c, err := protorpc.DialTimeout(network, addr, timeout) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
return &ProductServiceClient{c}, c, nil |
|
|
|
} |