75 lines
1.8 KiB
Go
75 lines
1.8 KiB
Go
// Code generated by goa v3.6.0, DO NOT EDIT.
|
|
//
|
|
// Service1 gRPC client
|
|
//
|
|
// Command:
|
|
// $ goa gen goa_example/design
|
|
|
|
package client
|
|
|
|
import (
|
|
"context"
|
|
service1pb "goa_example/gen/grpc/service1/pb"
|
|
|
|
goagrpc "goa.design/goa/v3/grpc"
|
|
goapb "goa.design/goa/v3/grpc/pb"
|
|
goa "goa.design/goa/v3/pkg"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// Client lists the service endpoint gRPC clients.
|
|
type Client struct {
|
|
grpccli service1pb.Service1Client
|
|
opts []grpc.CallOption
|
|
}
|
|
|
|
// NewClient instantiates gRPC client for all the Service1 service servers.
|
|
func NewClient(cc *grpc.ClientConn, opts ...grpc.CallOption) *Client {
|
|
return &Client{
|
|
grpccli: service1pb.NewService1Client(cc),
|
|
opts: opts,
|
|
}
|
|
}
|
|
|
|
// Signin calls the "Signin" function in service1pb.Service1Client interface.
|
|
func (c *Client) Signin() goa.Endpoint {
|
|
return func(ctx context.Context, v interface{}) (interface{}, error) {
|
|
inv := goagrpc.NewInvoker(
|
|
BuildSigninFunc(c.grpccli, c.opts...),
|
|
EncodeSigninRequest,
|
|
DecodeSigninResponse)
|
|
res, err := inv.Invoke(ctx, v)
|
|
if err != nil {
|
|
resp := goagrpc.DecodeError(err)
|
|
switch message := resp.(type) {
|
|
case *goapb.ErrorResponse:
|
|
return nil, goagrpc.NewServiceError(message)
|
|
default:
|
|
return nil, goa.Fault(err.Error())
|
|
}
|
|
}
|
|
return res, nil
|
|
}
|
|
}
|
|
|
|
// Secure calls the "Secure" function in service1pb.Service1Client interface.
|
|
func (c *Client) Secure() goa.Endpoint {
|
|
return func(ctx context.Context, v interface{}) (interface{}, error) {
|
|
inv := goagrpc.NewInvoker(
|
|
BuildSecureFunc(c.grpccli, c.opts...),
|
|
EncodeSecureRequest,
|
|
DecodeSecureResponse)
|
|
res, err := inv.Invoke(ctx, v)
|
|
if err != nil {
|
|
resp := goagrpc.DecodeError(err)
|
|
switch message := resp.(type) {
|
|
case *goapb.ErrorResponse:
|
|
return nil, goagrpc.NewServiceError(message)
|
|
default:
|
|
return nil, goa.Fault(err.Error())
|
|
}
|
|
}
|
|
return res, nil
|
|
}
|
|
}
|