github.com/erda-project/erda-infra@v1.0.10-0.20240327085753-f3a249292aeb/examples/service/protocol/pb/user_grpc.pb.go (about)

     1  // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
     2  // Source: user.proto
     3  
     4  package pb
     5  
     6  import (
     7  	context "context"
     8  
     9  	transport "github.com/erda-project/erda-infra/pkg/transport"
    10  	grpc1 "github.com/erda-project/erda-infra/pkg/transport/grpc"
    11  	grpc "google.golang.org/grpc"
    12  	codes "google.golang.org/grpc/codes"
    13  	status "google.golang.org/grpc/status"
    14  )
    15  
    16  // This is a compile-time assertion to ensure that this generated file
    17  // is compatible with the grpc package it is being compiled against.
    18  const _ = grpc.SupportPackageIsVersion5
    19  
    20  // UserServiceClient is the client API for UserService service.
    21  //
    22  // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
    23  type UserServiceClient interface {
    24  	// get user
    25  	GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
    26  	// update user
    27  	UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
    28  }
    29  
    30  type userServiceClient struct {
    31  	cc grpc1.ClientConnInterface
    32  }
    33  
    34  func NewUserServiceClient(cc grpc1.ClientConnInterface) UserServiceClient {
    35  	return &userServiceClient{cc}
    36  }
    37  
    38  func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
    39  	out := new(GetUserResponse)
    40  	err := c.cc.Invoke(ctx, "/erda.infra.example.UserService/GetUser", in, out, opts...)
    41  	if err != nil {
    42  		return nil, err
    43  	}
    44  	return out, nil
    45  }
    46  
    47  func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) {
    48  	out := new(UpdateUserResponse)
    49  	err := c.cc.Invoke(ctx, "/erda.infra.example.UserService/UpdateUser", in, out, opts...)
    50  	if err != nil {
    51  		return nil, err
    52  	}
    53  	return out, nil
    54  }
    55  
    56  // UserServiceServer is the server API for UserService service.
    57  // All implementations should embed UnimplementedUserServiceServer
    58  // for forward compatibility
    59  type UserServiceServer interface {
    60  	// get user
    61  	GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
    62  	// update user
    63  	UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
    64  }
    65  
    66  // UnimplementedUserServiceServer should be embedded to have forward compatible implementations.
    67  type UnimplementedUserServiceServer struct {
    68  }
    69  
    70  func (*UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
    71  	return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
    72  }
    73  func (*UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) {
    74  	return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented")
    75  }
    76  
    77  func RegisterUserServiceServer(s grpc1.ServiceRegistrar, srv UserServiceServer, opts ...grpc1.HandleOption) {
    78  	s.RegisterService(_get_UserService_serviceDesc(srv, opts...), srv)
    79  }
    80  
    81  var _UserService_serviceDesc = grpc.ServiceDesc{
    82  	ServiceName: "erda.infra.example.UserService",
    83  	HandlerType: (*UserServiceServer)(nil),
    84  	Methods:     []grpc.MethodDesc{},
    85  	Streams:     []grpc.StreamDesc{},
    86  	Metadata:    "user.proto",
    87  }
    88  
    89  func _get_UserService_serviceDesc(srv UserServiceServer, opts ...grpc1.HandleOption) *grpc.ServiceDesc {
    90  	h := grpc1.DefaultHandleOptions()
    91  	for _, op := range opts {
    92  		op(h)
    93  	}
    94  
    95  	_UserService_GetUser_Handler := func(ctx context.Context, req interface{}) (interface{}, error) {
    96  		return srv.GetUser(ctx, req.(*GetUserRequest))
    97  	}
    98  	var _UserService_GetUser_info transport.ServiceInfo
    99  	if h.Interceptor != nil {
   100  		_UserService_GetUser_info = transport.NewServiceInfo("erda.infra.example.UserService", "GetUser", srv)
   101  		_UserService_GetUser_Handler = h.Interceptor(_UserService_GetUser_Handler)
   102  	}
   103  
   104  	_UserService_UpdateUser_Handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   105  		return srv.UpdateUser(ctx, req.(*UpdateUserRequest))
   106  	}
   107  	var _UserService_UpdateUser_info transport.ServiceInfo
   108  	if h.Interceptor != nil {
   109  		_UserService_UpdateUser_info = transport.NewServiceInfo("erda.infra.example.UserService", "UpdateUser", srv)
   110  		_UserService_UpdateUser_Handler = h.Interceptor(_UserService_UpdateUser_Handler)
   111  	}
   112  
   113  	var serviceDesc = _UserService_serviceDesc
   114  	serviceDesc.Methods = []grpc.MethodDesc{
   115  		{
   116  			MethodName: "GetUser",
   117  			Handler: func(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   118  				in := new(GetUserRequest)
   119  				if err := dec(in); err != nil {
   120  					return nil, err
   121  				}
   122  				if interceptor == nil && h.Interceptor == nil {
   123  					return srv.(UserServiceServer).GetUser(ctx, in)
   124  				}
   125  				if h.Interceptor != nil {
   126  					ctx = context.WithValue(ctx, transport.ServiceInfoContextKey, _UserService_GetUser_info)
   127  				}
   128  				if interceptor == nil {
   129  					return _UserService_GetUser_Handler(ctx, in)
   130  				}
   131  				info := &grpc.UnaryServerInfo{
   132  					Server:     srv,
   133  					FullMethod: "/erda.infra.example.UserService/GetUser",
   134  				}
   135  				return interceptor(ctx, in, info, _UserService_GetUser_Handler)
   136  			},
   137  		},
   138  		{
   139  			MethodName: "UpdateUser",
   140  			Handler: func(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   141  				in := new(UpdateUserRequest)
   142  				if err := dec(in); err != nil {
   143  					return nil, err
   144  				}
   145  				if interceptor == nil && h.Interceptor == nil {
   146  					return srv.(UserServiceServer).UpdateUser(ctx, in)
   147  				}
   148  				if h.Interceptor != nil {
   149  					ctx = context.WithValue(ctx, transport.ServiceInfoContextKey, _UserService_UpdateUser_info)
   150  				}
   151  				if interceptor == nil {
   152  					return _UserService_UpdateUser_Handler(ctx, in)
   153  				}
   154  				info := &grpc.UnaryServerInfo{
   155  					Server:     srv,
   156  					FullMethod: "/erda.infra.example.UserService/UpdateUser",
   157  				}
   158  				return interceptor(ctx, in, info, _UserService_UpdateUser_Handler)
   159  			},
   160  		},
   161  	}
   162  	return &serviceDesc
   163  }