Browse Source

修改方法名

master v0.0.2
guzeng 3 years ago
parent
commit
a5838b9762
2 changed files with 33 additions and 33 deletions
  1. +32
    -32
      supplier.pb.go
  2. +1
    -1
      supplier.proto

+ 32
- 32
supplier.pb.go View File

@ -116,18 +116,18 @@ func (m *BoolResponse) GetValue() bool {
func init() { func init() {
} }
type ProductService interface {
type SupplierService interface {
Get(in *GetRequest, out *GetResponse) error Get(in *GetRequest, out *GetResponse) error
GetByUuid(in *GetUuidRequest, out *GetResponse) error GetByUuid(in *GetUuidRequest, out *GetResponse) error
IsOpen(in *GetRequest, out *BoolResponse) error IsOpen(in *GetRequest, out *BoolResponse) error
} }
// AcceptProductServiceClient accepts connections on the listener and serves requests
// AcceptSupplierServiceClient accepts connections on the listener and serves requests
// for each incoming connection. Accept blocks; the caller typically // for each incoming connection. Accept blocks; the caller typically
// invokes it in a go statement. // invokes it in a go statement.
func AcceptProductServiceClient(lis net.Listener, x ProductService) {
func AcceptSupplierServiceClient(lis net.Listener, x SupplierService) {
srv := rpc.NewServer() srv := rpc.NewServer()
if err := srv.RegisterName("ProductService", x); err != nil {
if err := srv.RegisterName("SupplierService", x); err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -140,26 +140,26 @@ func AcceptProductServiceClient(lis net.Listener, x ProductService) {
} }
} }
// 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 {
// RegisterSupplierService publish the given SupplierService implementation on the server.
func RegisterSupplierService(srv *rpc.Server, x SupplierService) error {
if err := srv.RegisterName("SupplierService", x); err != nil {
return err return err
} }
return nil return nil
} }
// NewProductServiceServer returns a new ProductService Server.
func NewProductServiceServer(x ProductService) *rpc.Server {
// NewSupplierServiceServer returns a new SupplierService Server.
func NewSupplierServiceServer(x SupplierService) *rpc.Server {
srv := rpc.NewServer() srv := rpc.NewServer()
if err := srv.RegisterName("ProductService", x); err != nil {
if err := srv.RegisterName("SupplierService", x); err != nil {
log.Fatal(err) log.Fatal(err)
} }
return srv 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 {
// ListenAndServeSupplierService listen announces on the local network address laddr
// and serves the given SupplierService implementation.
func ListenAndServeSupplierService(network, addr string, x SupplierService) error {
lis, err := net.Listen(network, addr) lis, err := net.Listen(network, addr)
if err != nil { if err != nil {
return err return err
@ -167,7 +167,7 @@ func ListenAndServeProductService(network, addr string, x ProductService) error
defer lis.Close() defer lis.Close()
srv := rpc.NewServer() srv := rpc.NewServer()
if err := srv.RegisterName("ProductService", x); err != nil {
if err := srv.RegisterName("SupplierService", x); err != nil {
return err return err
} }
@ -180,42 +180,42 @@ func ListenAndServeProductService(network, addr string, x ProductService) error
} }
} }
type ProductServiceClient struct {
type SupplierServiceClient struct {
*rpc.Client *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) {
// NewSupplierServiceClient returns a SupplierService rpc.Client and stub to handle
// requests to the set of SupplierService at the other end of the connection.
func NewSupplierServiceClient(conn io.ReadWriteCloser) (*SupplierServiceClient, *rpc.Client) {
c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn)) c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
return &ProductServiceClient{c}, c
return &SupplierServiceClient{c}, c
} }
func (c *ProductServiceClient) Get(in *GetRequest, out *GetResponse) error {
return c.Call("ProductService.Get", in, out)
func (c *SupplierServiceClient) Get(in *GetRequest, out *GetResponse) error {
return c.Call("SupplierService.Get", in, out)
} }
func (c *ProductServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error {
return c.Call("ProductService.GetByUuid", in, out)
func (c *SupplierServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error {
return c.Call("SupplierService.GetByUuid", in, out)
} }
func (c *ProductServiceClient) IsOpen(in *GetRequest, out *BoolResponse) error {
return c.Call("ProductService.IsOpen", in, out)
func (c *SupplierServiceClient) IsOpen(in *GetRequest, out *BoolResponse) error {
return c.Call("SupplierService.IsOpen", in, out)
} }
// DialProductService connects to an ProductService at the specified network address.
func DialProductService(network, addr string) (*ProductServiceClient, *rpc.Client, error) {
// DialSupplierService connects to an SupplierService at the specified network address.
func DialSupplierService(network, addr string) (*SupplierServiceClient, *rpc.Client, error) {
c, err := protorpc.Dial(network, addr) c, err := protorpc.Dial(network, addr)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
return &ProductServiceClient{c}, c, nil
return &SupplierServiceClient{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) {
// DialSupplierServiceTimeout connects to an SupplierService at the specified network address.
func DialSupplierServiceTimeout(network, addr string,
timeout time.Duration) (*SupplierServiceClient, *rpc.Client, error) {
c, err := protorpc.DialTimeout(network, addr, timeout) c, err := protorpc.DialTimeout(network, addr, timeout)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
return &ProductServiceClient{c}, c, nil
return &SupplierServiceClient{c}, c, nil
} }

+ 1
- 1
supplier.proto View File

@ -23,7 +23,7 @@ message BoolResponse {
} }
// rpc方法 // rpc方法
service ProductService {
service SupplierService {
rpc Get (GetRequest) returns (GetResponse); // 使id查询 rpc Get (GetRequest) returns (GetResponse); // 使id查询
rpc GetByUuid (GetUuidRequest) returns (GetResponse); // 使uuid查询 rpc GetByUuid (GetUuidRequest) returns (GetResponse); // 使uuid查询
rpc IsOpen (GetRequest) returns (BoolResponse); // rpc IsOpen (GetRequest) returns (BoolResponse); //

Loading…
Cancel
Save