|
|
@ -0,0 +1,183 @@ |
|
|
|
// Code generated by protoc-gen-go.
|
|
|
|
// source: product.proto
|
|
|
|
// DO NOT EDIT!
|
|
|
|
|
|
|
|
/* |
|
|
|
Package productrpc is a generated protocol buffer package. |
|
|
|
|
|
|
|
It is generated from these files: |
|
|
|
product.proto |
|
|
|
|
|
|
|
It has these top-level messages: |
|
|
|
GetRequest |
|
|
|
GetUuidRequest |
|
|
|
GetResponse |
|
|
|
*/ |
|
|
|
package productrpc |
|
|
|
|
|
|
|
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 { |
|
|
|
Id *string `protobuf:"bytes,1,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) GetId() string { |
|
|
|
if m != nil && m.Id != nil { |
|
|
|
return *m.Id |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
type GetUuidRequest struct { |
|
|
|
Uuid *string `protobuf:"bytes,1,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) 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 |
|
|
|
} |
|
|
|
|
|
|
|
func init() { |
|
|
|
} |
|
|
|
|
|
|
|
type ProductService interface { |
|
|
|
Get(in *GetRequest, out *GetResponse) error |
|
|
|
GetByUuid(in *GetUuidRequest, out *GetResponse) 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) |
|
|
|
} |
|
|
|
|
|
|
|
// 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 |
|
|
|
} |