|
|
@ -116,18 +116,18 @@ func (m *BoolResponse) GetValue() bool { |
|
|
|
func init() { |
|
|
|
} |
|
|
|
|
|
|
|
type ProductService interface { |
|
|
|
type SupplierService 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
|
|
|
|
// AcceptSupplierServiceClient 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) { |
|
|
|
func AcceptSupplierServiceClient(lis net.Listener, x SupplierService) { |
|
|
|
srv := rpc.NewServer() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
if err := srv.RegisterName("SupplierService", x); err != nil { |
|
|
|
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 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() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
if err := srv.RegisterName("SupplierService", 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 { |
|
|
|
// 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) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
@ -167,7 +167,7 @@ func ListenAndServeProductService(network, addr string, x ProductService) error |
|
|
|
defer lis.Close() |
|
|
|
|
|
|
|
srv := rpc.NewServer() |
|
|
|
if err := srv.RegisterName("ProductService", x); err != nil { |
|
|
|
if err := srv.RegisterName("SupplierService", x); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
@ -180,42 +180,42 @@ func ListenAndServeProductService(network, addr string, x ProductService) error |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type ProductServiceClient struct { |
|
|
|
type SupplierServiceClient 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) { |
|
|
|
// 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)) |
|
|
|
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) |
|
|
|
if err != nil { |
|
|
|
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) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
return &ProductServiceClient{c}, c, nil |
|
|
|
return &SupplierServiceClient{c}, c, nil |
|
|
|
} |