Able to get user by using name

This commit is contained in:
2024-11-03 01:40:36 +08:00
parent ea150608b4
commit 194d270904
15 changed files with 979 additions and 465 deletions

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc-gen-go-grpc v1.2.0
// - protoc v5.28.2
// source: user.proto
@@ -15,14 +15,8 @@ import (
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
UserService_GetUser_FullMethodName = "/proto.UserService/GetUser"
UserService_ListUser_FullMethodName = "/proto.UserService/ListUser"
UserService_ListUserRelative_FullMethodName = "/proto.UserService/ListUserRelative"
)
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// UserServiceClient is the client API for UserService service.
//
@@ -42,9 +36,8 @@ func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
}
func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserInfo, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UserInfo)
err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...)
err := c.cc.Invoke(ctx, "/proto.UserService/GetUser", in, out, opts...)
if err != nil {
return nil, err
}
@@ -52,9 +45,8 @@ func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opt
}
func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*MultipleUserInfo, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(MultipleUserInfo)
err := c.cc.Invoke(ctx, UserService_ListUser_FullMethodName, in, out, cOpts...)
err := c.cc.Invoke(ctx, "/proto.UserService/ListUser", in, out, opts...)
if err != nil {
return nil, err
}
@@ -62,9 +54,8 @@ func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, o
}
func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRelativeRequest, opts ...grpc.CallOption) (*ListUserRelativeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListUserRelativeResponse)
err := c.cc.Invoke(ctx, UserService_ListUserRelative_FullMethodName, in, out, cOpts...)
err := c.cc.Invoke(ctx, "/proto.UserService/ListUserRelative", in, out, opts...)
if err != nil {
return nil, err
}
@@ -73,7 +64,7 @@ func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRe
// UserServiceServer is the server API for UserService service.
// All implementations must embed UnimplementedUserServiceServer
// for forward compatibility.
// for forward compatibility
type UserServiceServer interface {
GetUser(context.Context, *GetUserRequest) (*UserInfo, error)
ListUser(context.Context, *ListUserRequest) (*MultipleUserInfo, error)
@@ -81,12 +72,9 @@ type UserServiceServer interface {
mustEmbedUnimplementedUserServiceServer()
}
// UnimplementedUserServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedUserServiceServer struct{}
// UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
type UnimplementedUserServiceServer struct {
}
func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*UserInfo, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
@@ -98,7 +86,6 @@ func (UnimplementedUserServiceServer) ListUserRelative(context.Context, *ListUse
return nil, status.Errorf(codes.Unimplemented, "method ListUserRelative not implemented")
}
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
func (UnimplementedUserServiceServer) testEmbeddedByValue() {}
// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServiceServer will
@@ -108,13 +95,6 @@ type UnsafeUserServiceServer interface {
}
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
// If the following call pancis, it indicates UnimplementedUserServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&UserService_ServiceDesc, srv)
}
@@ -128,7 +108,7 @@ func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_GetUser_FullMethodName,
FullMethod: "/proto.UserService/GetUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest))
@@ -146,7 +126,7 @@ func _UserService_ListUser_Handler(srv interface{}, ctx context.Context, dec fun
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_ListUser_FullMethodName,
FullMethod: "/proto.UserService/ListUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).ListUser(ctx, req.(*ListUserRequest))
@@ -164,7 +144,7 @@ func _UserService_ListUserRelative_Handler(srv interface{}, ctx context.Context,
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_ListUserRelative_FullMethodName,
FullMethod: "/proto.UserService/ListUserRelative",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).ListUserRelative(ctx, req.(*ListUserRelativeRequest))