user

package
v0.0.0-...-588936b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package user is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var File_user_user_proto protoreflect.FileDescriptor
View Source
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

func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUserHandlerClient

func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error

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

func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error

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
const (
	Sex_UNSPECTED Sex = 0
	Sex_MALE      Sex = 1
	Sex_FEMALE    Sex = 2
	Sex_OTHER     Sex = 3
)

func (Sex) Descriptor

func (Sex) Descriptor() protoreflect.EnumDescriptor

func (Sex) Enum

func (x Sex) Enum() *Sex

func (Sex) EnumDescriptor deprecated

func (Sex) EnumDescriptor() ([]byte, []int)

Deprecated: Use Sex.Descriptor instead.

func (Sex) Number

func (x Sex) Number() protoreflect.EnumNumber

func (Sex) String

func (x Sex) String() string

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) SetUser

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) Descriptor() ([]byte, []int)

Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.

func (*UserInfo) GetAddr

func (x *UserInfo) GetAddr() string

func (*UserInfo) GetAge

func (x *UserInfo) GetAge() int32

func (*UserInfo) GetEmail

func (x *UserInfo) GetEmail() string

func (*UserInfo) GetHeight

func (x *UserInfo) GetHeight() float32

func (*UserInfo) GetName

func (x *UserInfo) GetName() string

func (*UserInfo) GetSex

func (x *UserInfo) GetSex() string

func (*UserInfo) ProtoMessage

func (*UserInfo) ProtoMessage()

func (*UserInfo) ProtoReflect

func (x *UserInfo) ProtoReflect() protoreflect.Message

func (*UserInfo) Reset

func (x *UserInfo) Reset()

func (*UserInfo) String

func (x *UserInfo) String() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL