rpc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.2 KiB

// Code generated by protoc-gen-go.
// source: order.proto
// DO NOT EDIT!
/*
Package order is a generated protocol buffer package.
It is generated from these files:
order.proto
It has these top-level messages:
CreateRequest
CreateResponse
*/
package order
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
// 下单请求结构
type CreateRequest struct {
Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *CreateRequest) Reset() { *m = CreateRequest{} }
func (m *CreateRequest) String() string { return proto.CompactTextString(m) }
func (*CreateRequest) ProtoMessage() {}
func (m *CreateRequest) GetData() string {
if m != nil && m.Data != nil {
return *m.Data
}
return ""
}
func (m *CreateRequest) GetTime() string {
if m != nil && m.Time != nil {
return *m.Time
}
return ""
}
func (m *CreateRequest) GetSign() string {
if m != nil && m.Sign != nil {
return *m.Sign
}
return ""
}
// 下单响应结构
type CreateResponse struct {
Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *CreateResponse) Reset() { *m = CreateResponse{} }
func (m *CreateResponse) String() string { return proto.CompactTextString(m) }
func (*CreateResponse) ProtoMessage() {}
func (m *CreateResponse) GetData() string {
if m != nil && m.Data != nil {
return *m.Data
}
return ""
}
func (m *CreateResponse) GetTime() string {
if m != nil && m.Time != nil {
return *m.Time
}
return ""
}
func (m *CreateResponse) GetSign() string {
if m != nil && m.Sign != nil {
return *m.Sign
}
return ""
}
func init() {
}
type OrderService interface {
Create(in *CreateRequest, out *CreateResponse) error
CreateByCart(in *CreateRequest, out *CreateResponse) error
}
// AcceptOrderServiceClient accepts connections on the listener and serves requests
// for each incoming connection. Accept blocks; the caller typically
// invokes it in a go statement.
func AcceptOrderServiceClient(lis net.Listener, x OrderService) {
srv := rpc.NewServer()
if err := srv.RegisterName("OrderService", 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))
}
}
// RegisterOrderService publish the given OrderService implementation on the server.
func RegisterOrderService(srv *rpc.Server, x OrderService) error {
if err := srv.RegisterName("OrderService", x); err != nil {
return err
}
return nil
}
// NewOrderServiceServer returns a new OrderService Server.
func NewOrderServiceServer(x OrderService) *rpc.Server {
srv := rpc.NewServer()
if err := srv.RegisterName("OrderService", x); err != nil {
log.Fatal(err)
}
return srv
}
// ListenAndServeOrderService listen announces on the local network address laddr
// and serves the given OrderService implementation.
func ListenAndServeOrderService(network, addr string, x OrderService) error {
lis, err := net.Listen(network, addr)
if err != nil {
return err
}
defer lis.Close()
srv := rpc.NewServer()
if err := srv.RegisterName("OrderService", 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 OrderServiceClient struct {
*rpc.Client
}
// NewOrderServiceClient returns a OrderService rpc.Client and stub to handle
// requests to the set of OrderService at the other end of the connection.
func NewOrderServiceClient(conn io.ReadWriteCloser) (*OrderServiceClient, *rpc.Client) {
c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
return &OrderServiceClient{c}, c
}
func (c *OrderServiceClient) Create(in *CreateRequest, out *CreateResponse) error {
return c.Call("OrderService.Create", in, out)
}
func (c *OrderServiceClient) CreateByCart(in *CreateRequest, out *CreateResponse) error {
return c.Call("OrderService.CreateByCart", in, out)
}
// DialOrderService connects to an OrderService at the specified network address.
func DialOrderService(network, addr string) (*OrderServiceClient, *rpc.Client, error) {
c, err := protorpc.Dial(network, addr)
if err != nil {
return nil, nil, err
}
return &OrderServiceClient{c}, c, nil
}
// DialOrderServiceTimeout connects to an OrderService at the specified network address.
func DialOrderServiceTimeout(network, addr string,
timeout time.Duration) (*OrderServiceClient, *rpc.Client, error) {
c, err := protorpc.DialTimeout(network, addr, timeout)
if err != nil {
return nil, nil, err
}
return &OrderServiceClient{c}, c, nil
}