Documentation ¶
Overview ¶
Package user is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error
- func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error
- func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
- type Null
- type Page
- func (*Page) Descriptor() ([]byte, []int)deprecated
- func (x *Page) GetCount() int64
- func (x *Page) GetPageIndex() int64
- func (x *Page) GetPageSize() int64
- func (x *Page) GetPageTotal() int64
- func (x *Page) GetTotal() int64
- func (*Page) ProtoMessage()
- func (x *Page) ProtoReflect() protoreflect.Message
- func (x *Page) Reset()
- func (x *Page) String() string
- type UnimplementedUserServiceServer
- func (UnimplementedUserServiceServer) UserDelete(context.Context, *UserID) (*UserID, error)
- func (UnimplementedUserServiceServer) UserInfo(context.Context, *UserBase) (*UserBase, error)
- func (UnimplementedUserServiceServer) UserQueryAll(context.Context, *UserAllOption) (*UserAll, error)
- func (UnimplementedUserServiceServer) UserQueryOne(context.Context, *UserID) (*UserBase, error)
- type UnsafeUserServiceServer
- type UserAll
- type UserAllOption
- func (*UserAllOption) Descriptor() ([]byte, []int)deprecated
- func (x *UserAllOption) GetPage() *Page
- func (x *UserAllOption) GetSex() UserSex
- func (x *UserAllOption) GetUserName() string
- func (*UserAllOption) ProtoMessage()
- func (x *UserAllOption) ProtoReflect() protoreflect.Message
- func (x *UserAllOption) Reset()
- func (x *UserAllOption) String() string
- type UserBase
- func (*UserBase) Descriptor() ([]byte, []int)deprecated
- func (x *UserBase) GetId() int64
- func (x *UserBase) GetIphone() string
- func (x *UserBase) GetPassword() string
- func (x *UserBase) GetSex() UserSex
- func (x *UserBase) GetUserName() string
- func (*UserBase) ProtoMessage()
- func (x *UserBase) ProtoReflect() protoreflect.Message
- func (x *UserBase) Reset()
- func (x *UserBase) String() string
- type UserID
- type UserServiceClient
- type UserServiceServer
- type UserSex
Constants ¶
This section is empty.
Variables ¶
var ( UserSex_name = map[int32]string{ 0: "DEFAULT", 1: "MEN", 2: "WOMEN", } UserSex_value = map[string]int32{ "DEFAULT": 0, "MEN": 1, "WOMEN": 2, } )
Enum value maps for UserSex.
var File_user_user_proto protoreflect.FileDescriptor
var UserService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.UserService", HandlerType: (*UserServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "UserInfo", Handler: _UserService_UserInfo_Handler, }, { MethodName: "UserDelete", Handler: _UserService_UserDelete_Handler, }, { MethodName: "UserQueryOne", Handler: _UserService_UserQueryOne_Handler, }, { MethodName: "UserQueryAll", Handler: _UserService_UserQueryAll_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/user.proto", }
UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterUserServiceHandler ¶
func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterUserServiceHandler registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserServiceHandlerClient ¶
func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error
RegisterUserServiceHandlerClient registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserServiceClient" to call the correct interceptors.
func RegisterUserServiceHandlerFromEndpoint ¶
func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserServiceHandlerServer ¶
func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error
RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". UnaryRPC :call UserServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserServiceHandlerFromEndpoint instead.
func RegisterUserServiceServer ¶
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
Types ¶
type Null ¶
type Null struct {
// contains filtered or unexported fields
}
空消息
func (*Null) Descriptor
deprecated
func (*Null) ProtoMessage ¶
func (*Null) ProtoMessage()
func (*Null) ProtoReflect ¶
func (x *Null) ProtoReflect() protoreflect.Message
type Page ¶
type Page struct { // 页 PageIndex int64 `protobuf:"varint,1,opt,name=page_index,json=pageIndex,proto3" json:"page_index,omitempty"` // 每页大小 PageSize int64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` // 总页数 PageTotal int64 `protobuf:"varint,3,opt,name=page_total,json=pageTotal,proto3" json:"page_total,omitempty"` // 条数 Count int64 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"` // 总条数 Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"` // contains filtered or unexported fields }
分页
func (*Page) Descriptor
deprecated
func (*Page) GetPageIndex ¶
func (*Page) GetPageSize ¶
func (*Page) GetPageTotal ¶
func (*Page) ProtoMessage ¶
func (*Page) ProtoMessage()
func (*Page) ProtoReflect ¶
func (x *Page) ProtoReflect() protoreflect.Message
type UnimplementedUserServiceServer ¶
type UnimplementedUserServiceServer struct { }
UnimplementedUserServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedUserServiceServer) UserDelete ¶
func (UnimplementedUserServiceServer) UserQueryAll ¶
func (UnimplementedUserServiceServer) UserQueryAll(context.Context, *UserAllOption) (*UserAll, error)
func (UnimplementedUserServiceServer) UserQueryOne ¶
type UnsafeUserServiceServer ¶
type UnsafeUserServiceServer interface {
// contains filtered or unexported methods
}
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 result in compilation errors.
type UserAll ¶
type UserAll struct { // 用户信息 All []*UserBase `protobuf:"bytes,1,rep,name=all,proto3" json:"all,omitempty"` // 页数 Page *Page `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"` // contains filtered or unexported fields }
用户全部
func (*UserAll) Descriptor
deprecated
func (*UserAll) ProtoMessage ¶
func (*UserAll) ProtoMessage()
func (*UserAll) ProtoReflect ¶
func (x *UserAll) ProtoReflect() protoreflect.Message
type UserAllOption ¶
type UserAllOption struct { // 用户性别 Sex UserSex `protobuf:"varint,1,opt,name=sex,proto3,enum=user.UserSex" json:"sex,omitempty"` // 页数 Page *Page `protobuf:"bytes,2,opt,name=page,proto3" json:"page,omitempty"` // 用户名称 UserName string `protobuf:"bytes,3,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"` // contains filtered or unexported fields }
用户全部选项
func (*UserAllOption) Descriptor
deprecated
func (*UserAllOption) Descriptor() ([]byte, []int)
Deprecated: Use UserAllOption.ProtoReflect.Descriptor instead.
func (*UserAllOption) GetPage ¶
func (x *UserAllOption) GetPage() *Page
func (*UserAllOption) GetSex ¶
func (x *UserAllOption) GetSex() UserSex
func (*UserAllOption) GetUserName ¶
func (x *UserAllOption) GetUserName() string
func (*UserAllOption) ProtoMessage ¶
func (*UserAllOption) ProtoMessage()
func (*UserAllOption) ProtoReflect ¶
func (x *UserAllOption) ProtoReflect() protoreflect.Message
func (*UserAllOption) Reset ¶
func (x *UserAllOption) Reset()
func (*UserAllOption) String ¶
func (x *UserAllOption) String() string
type UserBase ¶
type UserBase struct { // @inject_tag: db:"id" Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // @inject_tag: db:"user_name" valid:"required~用户名称必须存在" UserName string `protobuf:"bytes,2,opt,name=user_name,json=userName,proto3" json:"user_name,omitempty"` // @inject_tag: db:"iphone" valid:"required~手机号必须存在" Iphone string `protobuf:"bytes,3,opt,name=iphone,proto3" json:"iphone,omitempty"` // @inject_tag: db:"password" Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` // @inject_tag: db:"sex" Sex UserSex `protobuf:"varint,5,opt,name=sex,proto3,enum=user.UserSex" json:"sex,omitempty"` // contains filtered or unexported fields }
注入标签: https://github.com/favadi/protoc-go-inject-tag 用户基本信息
func (*UserBase) Descriptor
deprecated
func (*UserBase) GetPassword ¶
func (*UserBase) GetUserName ¶
func (*UserBase) ProtoMessage ¶
func (*UserBase) ProtoMessage()
func (*UserBase) ProtoReflect ¶
func (x *UserBase) ProtoReflect() protoreflect.Message
type UserID ¶
type UserID struct { // 用户id Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*UserID) Descriptor
deprecated
func (*UserID) ProtoMessage ¶
func (*UserID) ProtoMessage()
func (*UserID) ProtoReflect ¶
func (x *UserID) ProtoReflect() protoreflect.Message
type UserServiceClient ¶
type UserServiceClient interface { // 用户资料 UserInfo(ctx context.Context, in *UserBase, opts ...grpc.CallOption) (*UserBase, error) // 用户删除 UserDelete(ctx context.Context, in *UserID, opts ...grpc.CallOption) (*UserID, error) // 用户查询一个 UserQueryOne(ctx context.Context, in *UserID, opts ...grpc.CallOption) (*UserBase, error) // 用户查询全部 UserQueryAll(ctx context.Context, in *UserAllOption, opts ...grpc.CallOption) (*UserAll, error) }
UserServiceClient is the client API for UserService service.
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.
func NewUserServiceClient ¶
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient
type UserServiceServer ¶
type UserServiceServer interface { // 用户资料 UserInfo(context.Context, *UserBase) (*UserBase, error) // 用户删除 UserDelete(context.Context, *UserID) (*UserID, error) // 用户查询一个 UserQueryOne(context.Context, *UserID) (*UserBase, error) // 用户查询全部 UserQueryAll(context.Context, *UserAllOption) (*UserAll, error) // contains filtered or unexported methods }
UserServiceServer is the server API for UserService service. All implementations must embed UnimplementedUserServiceServer for forward compatibility
type UserSex ¶
type UserSex int32
用户性别
func (UserSex) Descriptor ¶
func (UserSex) Descriptor() protoreflect.EnumDescriptor
func (UserSex) EnumDescriptor
deprecated
func (UserSex) Number ¶
func (x UserSex) Number() protoreflect.EnumNumber
func (UserSex) Type ¶
func (UserSex) Type() protoreflect.EnumType