Documentation ¶
Overview ¶
Package user is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error
- func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error
- func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
- type GetUserRequest
- func (*GetUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetUserRequest) GetFieldMask() *field_mask.FieldMask
- func (x *GetUserRequest) GetUserId() string
- func (*GetUserRequest) ProtoMessage()
- func (x *GetUserRequest) ProtoReflect() protoreflect.Message
- func (x *GetUserRequest) Reset()
- func (x *GetUserRequest) String() string
- type SetUserRequest
- func (*SetUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *SetUserRequest) GetFieldMask() *field_mask.FieldMask
- func (x *SetUserRequest) GetUserId() string
- func (*SetUserRequest) ProtoMessage()
- func (x *SetUserRequest) ProtoReflect() protoreflect.Message
- func (x *SetUserRequest) Reset()
- func (x *SetUserRequest) String() string
- type SetUserResponse
- type Sex
- type UnimplementedUserServer
- type UnsafeUserServer
- type UserClient
- type UserInfo
- func (*UserInfo) Descriptor() ([]byte, []int)deprecated
- func (x *UserInfo) GetAddr() string
- func (x *UserInfo) GetAge() int32
- func (x *UserInfo) GetEmail() string
- func (x *UserInfo) GetHeight() float32
- func (x *UserInfo) GetName() string
- func (x *UserInfo) GetSex() string
- func (*UserInfo) ProtoMessage()
- func (x *UserInfo) ProtoReflect() protoreflect.Message
- func (x *UserInfo) Reset()
- func (x *UserInfo) String() string
- type UserServer
Constants ¶
This section is empty.
Variables ¶
var ( Sex_name = map[int32]string{ 0: "UNSPECTED", 1: "MALE", 2: "FEMALE", 3: "OTHER", } Sex_value = map[string]int32{ "UNSPECTED": 0, "MALE": 1, "FEMALE": 2, "OTHER": 3, } )
Enum value maps for Sex.
var File_user_user_proto protoreflect.FileDescriptor
var User_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.v1.User", HandlerType: (*UserServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetUser", Handler: _User_GetUser_Handler, }, { MethodName: "SetUser", Handler: _User_SetUser_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/user.proto", }
User_ServiceDesc is the grpc.ServiceDesc for User service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterUserHandler ¶
RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserHandlerClient ¶
RegisterUserHandlerClient registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserClient" to call the correct interceptors.
func RegisterUserHandlerFromEndpoint ¶
func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserHandlerServer ¶
RegisterUserHandlerServer registers the http handlers for service User to "mux". UnaryRPC :call UserServer 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 RegisterUserHandlerFromEndpoint instead.
func RegisterUserServer ¶
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
Types ¶
type GetUserRequest ¶
type GetUserRequest struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` FieldMask *field_mask.FieldMask `protobuf:"bytes,2,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"` // contains filtered or unexported fields }
func (*GetUserRequest) Descriptor
deprecated
func (*GetUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
func (*GetUserRequest) GetFieldMask ¶
func (x *GetUserRequest) GetFieldMask() *field_mask.FieldMask
func (*GetUserRequest) GetUserId ¶
func (x *GetUserRequest) GetUserId() string
func (*GetUserRequest) ProtoMessage ¶
func (*GetUserRequest) ProtoMessage()
func (*GetUserRequest) ProtoReflect ¶
func (x *GetUserRequest) ProtoReflect() protoreflect.Message
func (*GetUserRequest) Reset ¶
func (x *GetUserRequest) Reset()
func (*GetUserRequest) String ¶
func (x *GetUserRequest) String() string
type SetUserRequest ¶
type SetUserRequest struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` FieldMask *field_mask.FieldMask `protobuf:"bytes,2,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"` // contains filtered or unexported fields }
func (*SetUserRequest) Descriptor
deprecated
func (*SetUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use SetUserRequest.ProtoReflect.Descriptor instead.
func (*SetUserRequest) GetFieldMask ¶
func (x *SetUserRequest) GetFieldMask() *field_mask.FieldMask
func (*SetUserRequest) GetUserId ¶
func (x *SetUserRequest) GetUserId() string
func (*SetUserRequest) ProtoMessage ¶
func (*SetUserRequest) ProtoMessage()
func (*SetUserRequest) ProtoReflect ¶
func (x *SetUserRequest) ProtoReflect() protoreflect.Message
func (*SetUserRequest) Reset ¶
func (x *SetUserRequest) Reset()
func (*SetUserRequest) String ¶
func (x *SetUserRequest) String() string
type SetUserResponse ¶
type SetUserResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // contains filtered or unexported fields }
func (*SetUserResponse) Descriptor
deprecated
func (*SetUserResponse) Descriptor() ([]byte, []int)
Deprecated: Use SetUserResponse.ProtoReflect.Descriptor instead.
func (*SetUserResponse) GetSuccess ¶
func (x *SetUserResponse) GetSuccess() bool
func (*SetUserResponse) ProtoMessage ¶
func (*SetUserResponse) ProtoMessage()
func (*SetUserResponse) ProtoReflect ¶
func (x *SetUserResponse) ProtoReflect() protoreflect.Message
func (*SetUserResponse) Reset ¶
func (x *SetUserResponse) Reset()
func (*SetUserResponse) String ¶
func (x *SetUserResponse) String() string
type Sex ¶
type Sex int32
func (Sex) Descriptor ¶
func (Sex) Descriptor() protoreflect.EnumDescriptor
func (Sex) EnumDescriptor
deprecated
func (Sex) Number ¶
func (x Sex) Number() protoreflect.EnumNumber
func (Sex) Type ¶
func (Sex) Type() protoreflect.EnumType
type UnimplementedUserServer ¶
type UnimplementedUserServer struct { }
UnimplementedUserServer must be embedded to have forward compatible implementations.
func (UnimplementedUserServer) GetUser ¶
func (UnimplementedUserServer) GetUser(context.Context, *GetUserRequest) (*UserInfo, error)
func (UnimplementedUserServer) SetUser ¶
func (UnimplementedUserServer) SetUser(context.Context, *SetUserRequest) (*SetUserResponse, error)
type UnsafeUserServer ¶
type UnsafeUserServer interface {
// contains filtered or unexported methods
}
UnsafeUserServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServer will result in compilation errors.
type UserClient ¶
type UserClient interface { GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserInfo, error) // 如何保证原子更新? SetUser(ctx context.Context, in *SetUserRequest, opts ...grpc.CallOption) (*SetUserResponse, error) }
UserClient is the client API for User 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 NewUserClient ¶
func NewUserClient(cc grpc.ClientConnInterface) UserClient
type UserInfo ¶
type UserInfo struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Sex string `protobuf:"bytes,2,opt,name=sex,proto3" json:"sex,omitempty"` Age int32 `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"` Height float32 `protobuf:"fixed32,4,opt,name=height,proto3" json:"height,omitempty"` Addr string `protobuf:"bytes,5,opt,name=addr,proto3" json:"addr,omitempty"` Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"` // contains filtered or unexported fields }
func (*UserInfo) Descriptor
deprecated
func (*UserInfo) ProtoMessage ¶
func (*UserInfo) ProtoMessage()
func (*UserInfo) ProtoReflect ¶
func (x *UserInfo) ProtoReflect() protoreflect.Message
type UserServer ¶
type UserServer interface { GetUser(context.Context, *GetUserRequest) (*UserInfo, error) // 如何保证原子更新? SetUser(context.Context, *SetUserRequest) (*SetUserResponse, error) // contains filtered or unexported methods }
UserServer is the server API for User service. All implementations must embed UnimplementedUserServer for forward compatibility